/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 540.0 KiB
#2 Accepted 1ms 540.0 KiB
#3 Accepted 1ms 356.0 KiB
#4 Accepted 1ms 312.0 KiB
#5 Accepted 1ms 448.0 KiB
#6 Accepted 1ms 540.0 KiB
#7 Accepted 1ms 496.0 KiB
#8 Accepted 1ms 516.0 KiB
#9 Accepted 10ms 1.324 MiB
#10 Accepted 10ms 1.277 MiB
#11 Accepted 10ms 1.332 MiB
#12 Accepted 1ms 540.0 KiB
#13 Accepted 1ms 540.0 KiB
#14 Accepted 7ms 1.324 MiB
#15 Accepted 7ms 1.277 MiB
#16 Accepted 7ms 1.324 MiB

Code

/**
 *  written by Binoy Barman .
**/

#include<bits/stdc++.h>
using namespace std;
#define nl '\n'
#define all(v) v.begin(), v.end()
#define Too_Many_Jobs int tts, tc = 1; cin >> tts; hell: while(tts--)
#define Dark_Lord_Binoy ios_base::sync_with_stdio(false); cin.tie(NULL);

#ifdef LOCAL
#include "unravel.hpp"
#else
#define dbg(...) 42
#endif
#define ll long long

int32_t main() {
Dark_Lord_Binoy
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll n, sum = 0, cnt = 0;
    cin >> n;
    vector<ll> a(n);
    for(auto &x : a) cin >> x, sum += x;
    if(sum & 1) {
        cout << -1 << nl;
        return 0;
    }
    for (int i = 0; i < n; i++) {
        sum += a[i];
        if(sum % 2 == 0) {
            sum = 0;
            cnt++;
        }
    }
    cout << cnt << nl;

    return 0;
}

Information

Submit By
Type
Submission
Problem
P1042 Array partition
Contest
TLE_Headquarters - round #1
Language
C++20 (G++ 13.2.0)
Submit At
2024-03-27 16:15:59
Judged At
2024-03-27 16:15:59
Judged By
Score
100
Total Time
10ms
Peak Memory
1.332 MiB