1269D - Domino for Young - CodeForces Solution


combinatorics constructive algorithms math *2000

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define TC ll t;cin>>t;while(t--)
#define sp ' '
#define el '\n'
using namespace std;
//ــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــAmr__Khaledــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــــ
void __JOKER__() {
    ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt", " r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    __JOKER__();
ll n,dom=0,f=0,c=0;cin>>n;vector<ll>v(n+1);
    for (int i = 1,j=0; i <= n; ++i) {
        cin>>v[i];
        c+=v[i]/2;
       if(v[i]%2){
           if(i%2)dom++;
           else f++;
       }

    }
    c+= min(f,dom);
    cout<<c<<el;
}


Comments

Submit
0 Comments
More Questions

Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum
Two Strings
Anagrams
Prime Number
Lexical Sorting Reloaded
1514A - Perfectly Imperfect Array
580A- Kefa and First Steps
1472B- Fair Division
996A - Hit the Lottery
MSNSADM1 Football