답안 #226174

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
226174 2020-04-22T17:45:27 Z osaaateiasavtnl Nizin (COCI16_nizin) C++14
100 / 100
69 ms 10236 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e6 + 7;
int a[N];
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }   
    int l = -1, r = n;
    int seg = 0;
    while (l < r - 1) {
        int suml = 0, sumr = 0;
        while (l < r - 1) {
            if (suml < sumr) {
                ++l;
                suml += a[l];
            }   
            else {
                --r;
                sumr += a[r];
            }   
            if (suml == sumr)
                break;
        }   
        if (suml == sumr) {
            seg += 2;
        }   
        else {
            seg += 1;
            break;
        }   
    }   
    cout << n - seg << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1152 KB Output is correct
2 Correct 11 ms 1408 KB Output is correct
3 Correct 11 ms 1332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 28 ms 3840 KB Output is correct
2 Correct 30 ms 4480 KB Output is correct
3 Correct 38 ms 5248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 53 ms 7800 KB Output is correct
2 Correct 61 ms 8440 KB Output is correct
3 Correct 63 ms 9208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 10044 KB Output is correct
2 Correct 69 ms 10236 KB Output is correct
3 Correct 69 ms 10236 KB Output is correct