/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 1ms 324.0 KiB
#3 Accepted 1ms 512.0 KiB
#4 Accepted 1ms 532.0 KiB
#5 Accepted 1ms 320.0 KiB
#6 Accepted 1ms 324.0 KiB
#7 Accepted 1ms 532.0 KiB
#8 Accepted 1ms 320.0 KiB
#9 Wrong Answer 10ms 1.27 MiB
#10 Accepted 10ms 1.07 MiB
#11 Wrong Answer 10ms 1.312 MiB

Code

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vl vector<long long>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define inv(a) for(auto &it : a) cin >> it;
#define outv(a) for(auto &it : a) cout << it << " ";cout<<"\n"
#define outv1(a) for(auto &it : a) cout << it << " "<<"\n";cout<<"\n"
#define pb push_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define INF  1e15
#define int long long
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
bool ok(int a, int b, int c) {
    return (a + b > c && b + c > a && a + c > b);
}

void solve() {
    int n;
    cin>>n;
    vl v(n);
    inv(v);
    int even=0,odd=0;
    for (int i = 0; i < n; i++)
    {
        if(v[i]&1) odd++;
        else even++;
    }
    if(odd&1) cout<<-1<<endl;
    else cout<<even+odd/2<<endl;
}

int32_t main() {
    fastio;
    
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    int T=1;
    // cin>>T;
    while (T--)
    {
        solve();
    }
    
    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:09:23
Judged At
2024-11-11 03:39:37
Judged By
Score
50
Total Time
10ms
Peak Memory
1.312 MiB