/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 484.0 KiB
#2 Accepted 2ms 536.0 KiB
#3 Accepted 2ms 512.0 KiB
#4 Accepted 2ms 480.0 KiB
#5 Accepted 2ms 496.0 KiB
#6 Accepted 2ms 336.0 KiB
#7 Accepted 2ms 512.0 KiB
#8 Accepted 2ms 496.0 KiB
#9 Accepted 16ms 1.254 MiB
#10 Accepted 16ms 1.277 MiB
#11 Accepted 16ms 1.117 MiB
#12 Accepted 2ms 540.0 KiB
#13 Accepted 2ms 516.0 KiB
#14 Accepted 12ms 1.316 MiB
#15 Accepted 13ms 1.32 MiB
#16 Accepted 13ms 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-11-11 03:39:14
Judged By
Score
100
Total Time
16ms
Peak Memory
1.324 MiB