# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
736177 |
2023-05-05T09:42:59 Z |
Nhoksocqt1 |
Nizin (COCI16_nizin) |
C++17 |
|
62 ms |
6260 KB |
#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define sz(x) int((x).size())
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
template<class X, class Y>
inline bool maximize(X &x, const Y &y) {return (x < y ? x = y, 1 : 0);}
template<class X, class Y>
inline bool minimize(X &x, const Y &y) {return (x > y ? x = y, 1 : 0);}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int Random(int l, int r) {
return uniform_int_distribution<int>(l, r)(rng);
}
const int MAXN = 1000006;
int val[MAXN], nArr;
void process() {
cin >> nArr;
for (int i = 1; i <= nArr; ++i) {
cin >> val[i];
}
if(nArr == 1) {
cout << "0\n";
return;
}
ll suml(val[1]), sumr(val[nArr]);
int result(0), l(1), r(nArr);
while(l < r) {
//cout << suml << ' ' << sumr << ' ' << l << ' ' << r << '\n';
if(suml == sumr) {
suml = val[++l], sumr = val[--r];
if(l >= r)
break;
continue;
}
++result;
if(suml < sumr) {
suml += val[++l];
} else {
sumr += val[--r];
}
if(l == r)
break;
}
cout << result << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
process();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
340 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 |
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 |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 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 |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
336 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 |
7 ms |
732 KB |
Output is correct |
2 |
Correct |
6 ms |
848 KB |
Output is correct |
3 |
Correct |
7 ms |
860 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
27 ms |
2268 KB |
Output is correct |
2 |
Correct |
24 ms |
2756 KB |
Output is correct |
3 |
Correct |
28 ms |
3256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
4764 KB |
Output is correct |
2 |
Correct |
51 ms |
5060 KB |
Output is correct |
3 |
Correct |
62 ms |
5632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
6096 KB |
Output is correct |
2 |
Correct |
60 ms |
6260 KB |
Output is correct |
3 |
Correct |
55 ms |
6184 KB |
Output is correct |