https://codeforces.me/contest/1478/problem/C -problem link I am getting error as "uninitialized value usage" in this line — s.insert(a[i]); Can anyone help me to fix this issue Thanks in advance!!
include
include<bits/stdc++.h>
using namespace std;
int main() {
int t;cin>>t; while(t--) { int n;cin>>n; int m=2*n; int a[m]; set s; for(int i=0;i<m;i++) { cin>>a[i]; s.insert(a[i]); } if(s.size()!=n) { cout<<"NO"<<endl; continue; } vector v; for(auto i:s) v.push_back(i); long long sum=0,f=1; // cout<<v[0]<<v[1]<<endl;; for(int i=n-1;i>=0;i--) { v[i]-=sum; if(v[i]>0&&v[i]%(2*(i+1))==0) { v[i]/=2*(i+1); sum+=v[i]*2; } else {//cout<<i<<" "<<v[i]<<sum; f=0; break; } } if(f==1) cout<<"YES"<<endl; else cout<<"NO"<<endl;
} return 0; } Can anyone help me to fix this issue Thanks in advance!!