433A - Kitahara Haruki's Gift - CodeForces Solution


brute force implementation *1100

Please click on ads to support us..

Python Code:

n = int(input())
w = list(map(int, input().split()))
one = w.count(100)
two = w.count(200)
b_200 = two%2
b_100 = one - (b_200*2)
if(b_100>=0 and b_100%2 == 0):
    print('YES')
else:
    print('NO')

C++ Code:

#include<bits/stdc++.h>
 
#define fi(n)           for(int i=0;i<n;i++)
#define fj(n)           for(int j=0;j<n;j++)
#define fk(n)           for(int k=0;k<n;k++)
 
typedef long long ll;
int N = 1000000007;
ll MAX = 1e18;
using namespace std;
 
typedef vector<int> vi;
typedef vector<ll> vll;
 
ll a, b, c, n, i, j, k, t, x, m, r, l;
 
 
void bansal(){
    cin>>n;
    b = 0;
    c = 0;
    fi(n){
        cin>>a;
        if(a==200)  c++;
        else    b++;
    }
    a = c*200 + b*100;
    a/=2;
    if(a%100){
        cout<<"NO";
        return;
    }

    if(a%200!=0&&b==0){
    
        cout<<"NO";
        return;
    }
    cout<<"YES";
}
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    bool f = false;
    string s[100], st;
    t=1;
    while(t){
        bansal();
        cout<<endl;
        t--;
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST
445. Add Two Numbers II
442. Find All Duplicates in an Array
437. Path Sum III
436. Find Right Interval
435. Non-overlapping Intervals
406. Queue Reconstruction by Height
380. Insert Delete GetRandom O(1)
332. Reconstruct Itinerary
368. Largest Divisible Subset
377. Combination Sum IV
322. Coin Change
307. Range Sum Query - Mutable
287. Find the Duplicate Number
279. Perfect Squares
275. H-Index II
274. H-Index
260. Single Number III
240. Search a 2D Matrix II