# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
738828 |
2023-05-09T14:15:38 Z |
mzv |
Nizin (COCI16_nizin) |
C++17 |
|
53 ms |
7956 KB |
#include <bits/stdc++.h>
#define ccd ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
using namespace std;
/* ------------------------ hi lol ------------------------ */
ll n,arr[1'000'001],le,ri,ans=0;
int main() {
ccd
cin >> n;
for (int i=1;i<=n;i++) {
cin >> arr[i];
}
le=1,ri=n;
while (le<ri) {
if (arr[le]==arr[ri]) {
le++; ri--;
continue;
}
else if ((arr[le]+arr[le+1])==arr[ri]) {
arr[le+1]+=arr[le];
ans++;
le++;
ri--;
}
else if ((arr[ri]+arr[ri-1])==arr[le]) {
arr[ri-1]+=arr[ri];
ans++;
le++;
ri--;
}
else {
if ((arr[ri]+arr[ri-1])<=arr[le]) {
arr[ri-1]+=arr[ri];
ri--;
ans++;
}
else if ((arr[le]+arr[le+1])<=arr[ri]){
arr[le+1]+=arr[le];
le++;
ans++;
}
else {
if ((arr[ri]+arr[ri-1])<arr[le]+arr[le+1]) {
arr[ri-1]+=arr[ri];
ri--;
ans++;
}
else {
arr[le+1]+=arr[le];
le++;
ans++;
}
}
}
}
cout << ans << endl;
}
# |
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 |
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 |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
876 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
3000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
6236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
53 ms |
7956 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |