Codeforces Global Round 19 1637C - Andrew and Stones Solution
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
long long t,n,i,odd,ocnt;
cin>>t;
while(t--)
{
odd=0;
ocnt=0;
cin>>n;
long long a[n+9];
for(i=0; i<n; i++)
cin>>a[i];
for(i=1; i<n-1; i++)
{
ocnt+=a[i]/2;
if(a[i]%2==1)
odd++;
}
if(ocnt==0)cout<<"-1"<<endl;
else if((n==3)&&(a[1]%2==1))cout<<"-1"<<endl;
else cout<<ocnt+odd<<endl;
}
return 0;
}
Thanks
ReplyDelete
ReplyDeleteHi, I am Jennifer from Web Magazine and Newsin USA your blogs really help us to develop our skills, I appreciated more articles to gather knowledge.
ReplyDeleteHi, I am Jennifer from Web Magazine and Newin USA your blogs really help us to develop our skills, I appreciated more articles to gather knowledge.
Thanks Jennifer for inspring commen and you blog site is very good. If you want to friendship with me ? Please contact this email: ahtonmoy16@gmail.com
ReplyDelete