# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
592006 |
2022-07-08T11:21:12 Z |
starchan |
Nizin (COCI16_nizin) |
C++17 |
|
76 ms |
25852 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
fast();
int n;
cin >> n;
vector<int> a(n+1);
vector<int> pref(n+1);
vector<int> suff(n+1);
for(int i = 1; i <= n; i++)
cin >> a[i];
pref[1] = a[1];
suff[n] = a[n];
for(int i = 2; i <= n; i++)
pref[i] = pref[i-1]+a[i];
for(int i = n-1; i >= 1; i--)
suff[i] = suff[i+1]+a[i];
int l = 1;
int r = n;
int ans = 1;
while(l < r)
{
if(pref[l] == suff[r])
{
ans+=2;
if(l+1 == r)
ans--;
l++;
r--;
continue;
}
if(pref[l] < suff[r])
l++;
else
r--;
}
cout << n-ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
324 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2260 KB |
Output is correct |
2 |
Correct |
8 ms |
2856 KB |
Output is correct |
3 |
Correct |
8 ms |
2892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
9044 KB |
Output is correct |
2 |
Correct |
28 ms |
11040 KB |
Output is correct |
3 |
Correct |
41 ms |
13044 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
19556 KB |
Output is correct |
2 |
Correct |
52 ms |
20624 KB |
Output is correct |
3 |
Correct |
55 ms |
23116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
25292 KB |
Output is correct |
2 |
Correct |
74 ms |
25852 KB |
Output is correct |
3 |
Correct |
63 ms |
25844 KB |
Output is correct |