/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 1ms 540.0 KiB
#2 Wrong Answer 1ms 540.0 KiB
#3 Wrong Answer 1ms 540.0 KiB
#4 Wrong Answer 1ms 540.0 KiB
#5 Wrong Answer 1ms 540.0 KiB
#6 Wrong Answer 1ms 540.0 KiB
#7 Wrong Answer 1ms 324.0 KiB
#8 Wrong Answer 1ms 540.0 KiB
#9 Wrong Answer 7ms 1.898 MiB
#10 Wrong Answer 7ms 1.883 MiB
#11 Wrong Answer 7ms 1.898 MiB
#12 Wrong Answer 1ms 540.0 KiB
#13 Wrong Answer 1ms 332.0 KiB
#14 Wrong Answer 5ms 1.316 MiB
#15 Wrong Answer 5ms 1.277 MiB
#16 Wrong Answer 5ms 1.316 MiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,n) for(ll i=0;i<n;i++)
#define m(a,b,c) max(a,max(b,c))
#define N ll n;cin >> n;
#define Nk ll n,k;cin >> n >> k;
#define A ll a[n];f(i,n) cin >> a[i];
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr);
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define S string s;cin>>s;
#define pb push_back

int main()
{
   FAST_IO;
   N;
   A;
   vector<ll>v;
   f(i,n)
   {
       if(a[i]%2)
       {
           v.pb(i);
       }
   }
   if(v.size()%2)
   {
       cout<<-1;
   }
   else
   {
    //   ll s=0;
    //   for(ll i=0;i<v.size();i=i+2)
    //   {
    //       s+=v[i+1]-v[i]+1;
    //   }
    //   cout<<n-s+v.size()/2;
        ll odd=0,c=0;
        f(i,n)
        {
            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++17 (G++ 13.2.0)
Submit At
2024-05-06 13:02:02
Judged At
2024-05-06 13:02:02
Judged By
Score
0
Total Time
7ms
Peak Memory
1.898 MiB