Submission #1814949
Source Code Expand
#include <bits/stdc++.h> using namespace std; long n,a[200005],Min[200005],kq=0,Min2; int main(){ ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL); cin >> n; for(int i=1;i<=n;i++){ cin >> a[i]; } Min[n]=a[n]; for(int i=n-1;i>=1;i--){ if(a[i]<Min[i+1]) Min[i]=a[i]; else Min[i]=Min[i+1]; } for(int i=1;i<=n;i++){ Min2=a[i]; for(int j=i;j<=n;j++){ if(a[j]==Min[j]){ kq+=Min[j]*(n-j+1); break; } else if(a[j]<Min2) { Min2=a[j]; kq+=Min2; } else kq+=Min2; //cout << kq << " "; } } cout << kq; }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | vjudge5 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 724 Byte |
Status | TLE |
Exec Time | 2103 ms |
Memory | 3328 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | 3328 KB |
corner1 | TLE | 2103 ms | 3328 KB |
corner2 | AC | 1 ms | 256 KB |
corner3 | TLE | 2103 ms | 3328 KB |
example0 | AC | 1 ms | 256 KB |
example1 | AC | 1 ms | 256 KB |
example2 | AC | 1 ms | 256 KB |
maxrand0 | TLE | 2103 ms | 3328 KB |
maxrand1 | TLE | 2103 ms | 3328 KB |
maxrand2 | TLE | 2103 ms | 3328 KB |
rand0 | AC | 1 ms | 256 KB |
rand1 | AC | 1 ms | 256 KB |
rand2 | AC | 1 ms | 256 KB |