Submission #1814948
Source Code Expand
#include<bits/stdc++.h> #define endl '\n' #define N 200005 using namespace std; struct kieu{long gt,vt;}; kieu st[N]; long a[N], n,so,kq; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; st[0]={0,0}; so=0; for(long i=1;i<=n;++i) cin>>a[i]; for(long i=1;i<=n+1;++i){ while(a[i]<st[so].gt){ kq+=st[so].gt*(i-st[so].vt)*(st[so].vt-st[so-1].vt); --so; } st[++so]={a[i],i}; } cout<<kq; }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | vjudge4 |
Language | C++14 (GCC 5.4.1) |
Score | 400 |
Code Size | 426 Byte |
Status | AC |
Exec Time | 20 ms |
Memory | 4992 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2 |
All | corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner0 | AC | 19 ms | 4992 KB |
corner1 | AC | 18 ms | 1792 KB |
corner2 | AC | 1 ms | 256 KB |
corner3 | AC | 19 ms | 4352 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | AC | 20 ms | 1792 KB |
maxrand1 | AC | 20 ms | 1792 KB |
maxrand2 | AC | 20 ms | 1792 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |