#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000100
long long vet[MAXN];
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);
int n;
cin >> n;
for(int i=1; i<=n; i++){
cin >> vet[i];
}
int resp=0;
int atuali=0, atualj=0;
for(int i=1, j=n; i<j;){
if(vet[i]+atuali==vet[j]+atualj){
atuali=atualj=0;
i++;
j--;
continue;
}
resp++;
if(vet[i]+atuali<vet[j]+atualj){
atuali+=vet[i];
i++;
continue;
}
else{
atualj+=vet[j];
j--;
continue;
}
}
cout << resp << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
464 KB |
Output is correct |
3 |
Correct |
2 ms |
464 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
544 KB |
Output is correct |
2 |
Correct |
2 ms |
544 KB |
Output is correct |
3 |
Correct |
2 ms |
648 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
648 KB |
Output is correct |
2 |
Correct |
2 ms |
648 KB |
Output is correct |
3 |
Correct |
2 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
780 KB |
Output is correct |
2 |
Correct |
2 ms |
780 KB |
Output is correct |
3 |
Correct |
2 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
780 KB |
Output is correct |
2 |
Correct |
2 ms |
780 KB |
Output is correct |
3 |
Correct |
2 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
780 KB |
Output is correct |
2 |
Correct |
2 ms |
780 KB |
Output is correct |
3 |
Correct |
2 ms |
780 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1148 KB |
Output is correct |
2 |
Correct |
9 ms |
1404 KB |
Output is correct |
3 |
Correct |
9 ms |
1404 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
38 ms |
3452 KB |
Output is correct |
2 |
Correct |
34 ms |
3964 KB |
Output is correct |
3 |
Correct |
40 ms |
4604 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
77 ms |
6552 KB |
Output is correct |
2 |
Correct |
60 ms |
6816 KB |
Output is correct |
3 |
Correct |
70 ms |
7676 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
76 ms |
8316 KB |
Output is correct |
2 |
Correct |
75 ms |
8452 KB |
Output is correct |
3 |
Correct |
75 ms |
8452 KB |
Output is correct |