Codeforces Round #693 (Div. 3) 1472D - Even-Odd Game Solution



 Problem Link: https:   https://codeforces.com/contest/1472/problem/D

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()
{
    long long n,t,i,sa,sb;
    cin>>t;
    while(t--)
    {
        sa=sb=0;
        cin>>n;
        long long a[n+9];
        for(i=1; i<=n; i++)
        {
            cin>>a[i];
        }
        sort(a+1,a+n+1);
        for(i=n; i>=1; i=i-2)
        {
            if(a[i]%2==0)
                sa+=a[i];
        }
        for(i=n-1; i>=1; i=i-2)
        {
            if(a[i]%2==1)
                sb+=a[i];
        }
        if(sa>sb)
            cout<<"Alice"<<endl;
        else if(sa<sb)
            cout<<"Bob"<<endl;
        else
            cout<<"Tie"<<endl;
    }
}

 

No comments

Most View Post

Recent post

Codeforces Round 925 (Div. 3) 1931D. Divisible Pairs Solution

    Problem Link  :   https://codeforces.com/contest/1931/problem/D S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. ...

Powered by Blogger.