Codeforces round 794 div 2 problem A

Revision en1, by avinash_jha_04sep, 2022-05-25 22:57:34

What is wrong in my code I am pasting my code here of today contest problem A... I am little confused why it is giving NO in 3rd test case Anyone please explain...

include <bits/stdc++.h>

using namespace std;

int main() { int t; cin>>t; while(t--){ int n; cin>>n; int a[n]; int sum = 0; for(int i = 0; i <= n-1; i++){ cin>>a[i]; sum = sum + a[i]; } for(int i = 0; i <= n-1; i++){ if((sum — a[i])== a[i]*(n — 1)){ cout<<"YES"<<endl;

}   
 }

cout<<"NO"<<endl;

}

}

Tags codeforces, codeforces div2

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English avinash_jha_04sep 2022-05-25 23:02:35 1 Pls check this code
en1 English avinash_jha_04sep 2022-05-25 22:57:34 647 Initial revision (published)