/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 328.0 KiB
#2 Accepted 2ms 540.0 KiB
#3 Accepted 2ms 496.0 KiB
#4 Accepted 2ms 332.0 KiB
#5 Accepted 2ms 552.0 KiB
#6 Accepted 2ms 400.0 KiB
#7 Accepted 2ms 332.0 KiB
#8 Accepted 2ms 492.0 KiB
#9 Wrong Answer 17ms 1.312 MiB
#10 Accepted 17ms 1.312 MiB
#11 Wrong Answer 17ms 1.324 MiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pair<int,int>>
#define pb push_back
#define ts to_string
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b) / gcd(a,b)
#define srt(v) sort(v.begin(), v.end())
#define all(v) v.begin(), v.end()
#define rev(v) reverse(all(v))
#define cinv(v) for(auto it : v) cin >> it;
#define coutv(v) for(auto it : v) cout << it << ' '; cout << endl;
#define maxv(v) max_element(all(v))
#define minv(v) min_element(all(v))
#define F first
#define S second
#define pii pair<int,int>

const ll MOD = 1e9+7;
const int N = 1e5+10;
int hash[N];

ll bigMod(ll a, ll b, ll mod = 1e9+7) {
    if(b == 0) return 1 % mod;
    ll ans = bigMod(a, b / 2, mod);
    ans = (ans * ans) % mod;
    if(b % 2 == 1) ans = (ans * a) % mod;
    return ans;
}

bool neg(vl v) {
    for(int num : v) {
        if(num >= 0) {
            return false;
        }
    }
    return true;
}

ll maxSubarraySum(vl v, ll n) {
    ll sum = 0, mx = LONG_MIN;
    for(ll i = 0; i < n; ++i) {
        sum += v[i];
        if(sum > mx) mx = sum;
        if(sum < 0) sum = 0;
    }
    return mx;
}

vl div(ll n) {
    vl v;
    for(ll i = 1; i <= sqrt(n); ++i) {
        if(n % i == 0) {
            if(n / i == i) v.pb(i);
            else {
                v.pb(i);
                v.pb(n / i);
            }
        }
    }
    return v;
}

int cnt(int a) {
    int x = 0;
    while(a != 0) {
        a = a & a - 1;
        x++;
    }
    return x;
}

ll ans(ll a, ll b, ll c){
    ll aa = a;
    a += max(0LL, b - a + 1);
    a += max(0LL, c - a + 1);
    return a - aa;
}

void fastIO() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

void raju_sir_is_love() {
    int n;
    cin >> n;
    vl a(n);
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll c = 0, sum = 0;
    for(int i = 0; i < n; ++i) {
        if(a[i] % 2 == 0) c++;
        else {
            sum += a[i];
            if(sum % 2 == 0) {
                c++;
                sum = 0;
            }
        }
    }
    if(sum % 2 != 0) cout << -1 << endl;
    else cout << c << endl;
    return;
}

int main() {
    fastIO();
    read:
    /*ll t;
    cin >> t;
    while(t--) {
        raju_sir_is_love();
    }*/
    raju_sir_is_love();
    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:48:26
Judged At
2024-11-11 03:38:02
Judged By
Score
50
Total Time
17ms
Peak Memory
1.324 MiB