Codeforces Round #436 (Div. 2), problem: (A) Fair Game Solution In C/C++

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include<cstdio>
#include<iostream>
using namespace std;

int n,cnt,ans,A,B;
int buck[500];

int main(){
scanf(“%d”,&n);

for(int i = 1;i <= n;i++){
cin >> cnt;
if(!buck[cnt]){
ans++;
if(A) B = cnt;
else A = cnt;
}
buck[cnt]++;
}

if(ans == 2 && buck[A] == buck[B]) printf(“YES\n%d %d”,A,B);
else printf(“NO”);

return 0;
}

📦 Looking for Codeforces Round 436 Div Problem Fair? Check the best deals on Amazon.

🛒 Shop Codeforces Round 436 Div Problem Fair on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

Affiliate Disclosure: This post contains Amazon affiliate links. If you purchase through these links, eBlogarithm may earn a commission at no extra cost to you. Prices and availability are subject to change.

#include<cstdio>
#include<iostream>
using namespace std;

int n,cnt,ans,A,B;
int buck[500];

int main(){
scanf(“%d”,&n);

for(int i = 1;i <= n;i++){
cin >> cnt;
if(!buck[cnt]){
ans++;
if(A) B = cnt;
else A = cnt;
}
buck[cnt]++;
}

if(ans == 2 && buck[A] == buck[B]) printf(“YES\n%d %d”,A,B);
else printf(“NO”);

return 0;
}

📦 Looking for Codeforces Round 436 Div Problem Fair? Check the best deals on Amazon.

🛒 Shop Codeforces Round 436 Div Problem Fair on Amazon

As an Amazon Associate, eBlogarithm earns from qualifying purchases. Prices and availability are subject to change.

More from author

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Related posts

Advertismentspot_img

Latest posts

Lil Durk Found Not Guilty in Federal Murder-for-Hire Trial

In a dramatic conclusion to one of the hip-hop community's most closely watched legal battles, Chicago rapper Lil Durk has been found not guilty...

The Ultimate Viral Kitchen Gadgets Guide You Didnt Know You Needed

📢 As an Amazon Associate, I earn from qualifying purchases.I stumbled across this while desperately trying to fix a recurring problem in my routine....

Stop Buying Cheap Alternatives This Viral Kitchen Gadgets Is the Real Deal

📢 As an Amazon Associate, I earn from qualifying purchases.If you had told me six months ago that a single purchase would change how...

Want to stay up to date with the latest news?

We would love to hear from you! Please fill in your details and we will stay in touch. It's that simple!