TopCoder High School SRM 43 Level one - 250 pt - Transform Array editorial: http://community.topcoder.com/tc?module=Static&d1=hs&d2=match_editorials&d3=hs_srm43
TopCoder High School SRM 43 Level one - 250 pt - Transform Array solution:
#include <iostream> #include <vector> #include <algorithm> using namespace std; class TransformArray { public: int doTransform(vector <int> a) { int cnt=0; sort(a.begin(), a.end()); for(int i=1; i<a.size(); i++) cnt+=a[i-1], a[i]-=a[i-1], a[i-1]=0; return cnt; } };
No comments:
Post a Comment