ankitsinha3005's blog

By ankitsinha3005, history, 6 years ago, In English

Hi codeforces community, I'm new to codeforces and also a beginner in competitive coding.In the previous contest, i tried to solved this question.Your text to link here... from Codeforces Round #449(Div2). It is failing in test case 50 .Help from community will be highly appreciated . My code is below. ~~~~~

Your code here...

~~~~~

include

include <bits/stdc++.h>

using namespace std;

int main() { int n,sum1=0,sum2=0; cin>>n; vector ar(n); for(int i=0;i<n;i++) { cin>>ar[i]; } sort(ar.begin(),ar.end()); reverse(ar.begin(),ar.end()); for(int j=0;j<n;j++) {

        if(sum2>=sum1)
        sum1=sum1+ar[j];
        else
        sum2=sum2+ar[j];
         }

  if(sum1>=sum2)
  cout<<sum1-sum2;
  else
  cout<<sum2-sum1;

return 0;

}

Full text and comments »

  • Vote: I like it
  • -11
  • Vote: I do not like it

By ankitsinha3005, history, 6 years ago, In English

Hi codeforces community, I'm new to codeforces and also a beginner in competitive coding.In the previous contest, i tried to solved this question . "http://codeforces.com/contest/879/problem/B ". the code run perfectly on my compiler ,but it failed to run in some test cases codeforces compiler .i tried in few other online compiler, they gave the same response as my compiler gave. My solution "http://codeforces.com/contest/879/submission/31767149". So i request if someone could help from the community.

Thank you in advance.

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it