codechef SALARY - "The Minimum Number Of Moves" editorial : http://discuss.codechef.com/questions/5144/salary-editorial
codechef SALARY - "The Minimum Number Of Moves" solution : http://ideone.com/80xvWL
#include <iostream>#include <cstdio>
using namespace std;
int main() {
int t, n, w[105], s, min;
scanf("%d", &t);
while(t--) {
s=0;
min=1000000;
scanf("%d", &n);
for(int i=0; i<n; i++) {
scanf("%d", &w[i]);
if(w[i]<min) min=w[i];
s+=w[i];
}
printf("%d\n", s-n*min);
}
return 0;
}
No comments:
Post a Comment