#include <iostream>
#include <numeric>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define sp ' '
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << endl
#define prs(XX) cout << XX << " "
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 13;
const int mINF = -2e9 - 13;
const double PI = 3.14159265358979;
const double EPS = 1e-9;
int N, hamle = 0;
vll A;
int main(int argc, char **argv){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cin >> N; A.resize(N+1); for(int i = 1; i <= N; ++i) cin >> A[i];
int bas = 1, son = N;
while(bas < son){
if(A[bas] == A[son]){ bas++, son--; continue; }
else{
int bastoplam = A[bas], sontoplam = A[son];
while(bastoplam != sontoplam){
//cout << bastoplam << sp << sontoplam << endl;
if(bas == son){ break;}
if(bastoplam < sontoplam){
bastoplam += A[++bas];
hamle++;
}
else{
sontoplam += A[--son];
hamle++;
}
}
bas++, son--;
}
}
cout << hamle << endl;
return 0;
}
//cikisir
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
248 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
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 |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
8 ms |
1144 KB |
Output is correct |
2 |
Correct |
10 ms |
1400 KB |
Output is correct |
3 |
Correct |
10 ms |
1400 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
32 ms |
3788 KB |
Output is correct |
2 |
Correct |
36 ms |
4468 KB |
Output is correct |
3 |
Correct |
42 ms |
5316 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
63 ms |
7852 KB |
Output is correct |
2 |
Correct |
70 ms |
8312 KB |
Output is correct |
3 |
Correct |
74 ms |
9272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
81 ms |
10104 KB |
Output is correct |
2 |
Correct |
85 ms |
10288 KB |
Output is correct |
3 |
Correct |
84 ms |
10288 KB |
Output is correct |