# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
94155 |
2019-01-16T11:56:51 Z |
MrTEK |
Nizin (COCI16_nizin) |
C++14 |
|
99 ms |
12128 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> ii;
const int N = 1e6 + 5;
int n,a[N];
ll pre[N];
ll get(int l,int r) {
return pre[r] - pre[l - 1];
}
int f(int l,int r) {
if (l >= r)
return 0;
for (int i = l ; i < r ; i++) {
ll temp = get(l,i);
int sl = i + 1, sr = r;
while(sl < sr) {
int mid = (sl + sr - 1) / 2;
if (get(mid,r) > temp)
sl = mid + 1;
else
sr = mid;
}
if (get(sl,r) == temp)
return i - l + r - sl + f(i + 1,sl - 1);
}
return r - l;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
cin >> n;
for (int i = 1 ; i <= n ; i++) {
cin >> a[i];
pre[i] = pre[i - 1] + a[i];
}
cout << f(1,n);
}
# |
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 |
376 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 |
380 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 |
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 |
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 |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
1272 KB |
Output is correct |
2 |
Correct |
10 ms |
1528 KB |
Output is correct |
3 |
Correct |
11 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
4456 KB |
Output is correct |
2 |
Correct |
41 ms |
5340 KB |
Output is correct |
3 |
Correct |
50 ms |
6276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
75 ms |
9308 KB |
Output is correct |
2 |
Correct |
78 ms |
9720 KB |
Output is correct |
3 |
Correct |
87 ms |
10924 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
96 ms |
11996 KB |
Output is correct |
2 |
Correct |
98 ms |
12024 KB |
Output is correct |
3 |
Correct |
99 ms |
12128 KB |
Output is correct |