# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
94146 | 2019-01-16T11:45:29 Z | hamzqq9 | Nizin (COCI16_nizin) | C++14 | 90 ms | 4200 KB |
#include<bits/stdc++.h> #define st first #define nd second #define pb push_back #define ppb pop_back #define ppf pop_front #define umax(x,y) x=max(x,y) #define umin(x,y) x=min(x,y) #define ll long long #define ii pair<int,int> #define iii pair<ii,int> #define iiii pair<ii,ii> #define sz(x) ((int) x.size()) #define orta ((bas+son)/2) #define all(x) x.begin(),x.end() #define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" " #define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar() #define pw(x) (1<<(x)) #define inf 1000000000000000000ll #define MOD 1000000007 #define N 1000006 #define M 15000005 #define LOG 20 #define KOK 650 #define EPS 0.00001 using namespace std; int n; int a[N]; int main() { // freopen("input.txt","r",stdin); scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",a+i); } int ptr=n+1; int ans=n-1; ll pre=0; ll suf=0; int lans=-1,rans=-1; for(int i=1;i<=n && ptr>i;i++) { pre+=a[i]; lans++; while(ptr-1>i && suf+a[ptr-1]<=pre) { suf+=a[--ptr]; rans++; } if(suf==pre) { umin(ans,lans+rans+max(0,(ptr-i-1)-1)); lans--; rans--; } } printf("%d",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 252 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 632 KB | Output is correct |
2 | Correct | 10 ms | 760 KB | Output is correct |
3 | Correct | 10 ms | 632 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 31 ms | 1656 KB | Output is correct |
2 | Correct | 38 ms | 2020 KB | Output is correct |
3 | Correct | 45 ms | 2336 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 3236 KB | Output is correct |
2 | Correct | 69 ms | 3456 KB | Output is correct |
3 | Correct | 78 ms | 3876 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 86 ms | 4192 KB | Output is correct |
2 | Correct | 90 ms | 4188 KB | Output is correct |
3 | Correct | 90 ms | 4200 KB | Output is correct |