Where it is crashing?

Правка en1, от Aayuushh19, 2022-08-23 21:48:10

void solve(){ ll n;cin>>n; ll flag =0; vll b(n+2); FOR(i,0,n+2){ cin>>b[i]; } ll mx = *max_element(all(b)); sort(b.begin(),b.end()); ll sum = accumulate(all(b),0); sum = sum-b[n+1]; ll s2 = sum-b[n]; dbg(sum); dbg(s2); ll x=-1; for(ll i=0;i<n+1;i++){ if(sum-b[i]==mx){ x=i; break; } } if(x==-1){ ll s=0; for(ll i=0;i<n;i++){ s+=b[i]; } dbg(s); if(s==b[n]){ flag=1; for(ll i=0;i<n;i++){ cout<<b[i]<<" "; } cout<<endl; } } else{ flag =1; for(ll i=0;i<n+1;i++){ if(i!=x){ cout<<b[i]<<" "; } } cout<<endl; } if(flag==0) cout<<-1<<endl;

}

https://codeforces.net/contest/1512/problem/D

Теги maths, implementations, *1200

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский Aayuushh19 2022-09-12 07:32:16 23 Tiny change: '\n~~~~~\nvoi' -> '~~~~~\nvoi'
en1 Английский Aayuushh19 2022-08-23 21:48:10 1003 Initial revision (published)