/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 532.0 KiB
#2 Wrong Answer 2ms 324.0 KiB

Code

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

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n;
    cin >> n;
    
    ll a[n];
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    
    ll d=0;
    for (ll i = 0; i < n; i++)
    {
        if (a[i] % 2)
        {
            d++;
        }
    }
    
    if (d % 2)
    {
        cout << -1;
    }
    else
    {
        ll odd = 0, c = 0;
        for (ll i = 0; i < n; i++)
        {
            if (a[i] % 2)
            {
                odd++;
                if (odd == 2)
                {
                    c++;
                    odd = 0;
                }
            }
            else if (odd == 0)
            {
                c++;
            }
        }
        cout << c;
    }
   
   return 0;
}

Information

Submit By
Type
Submission
Problem
P1042 Array partition
Language
C++20 (G++ 13.2.0)
Submit At
2024-05-06 13:09:02
Judged At
2024-11-11 03:35:35
Judged By
Score
0
Total Time
2ms
Peak Memory
532.0 KiB