Codeforces 758A:Holiday Of Equality(水题)
http://codeforces.com/problemset/problem/758/A
题意:给出n个值,求这里面每个值都要变成最大的那个数,总共需要加上多少。
思路:找出最大的直接算。
1 #include <cstdio> 2 #include <algorithm> 3 #include <iostream> 4 #include <cstring> 5 #include <string> 6 #include <cmath> 7 #include <queue> 8 #include <vector> 9 #include <map> 10 #include <set> 11 #include <stack> 12 using namespace std; 13 #define INF 0x3f3f3f3f 14 #define N 100010 15 typedef long long LL; 16 int num[N]; 17 18 int main() { 19 int n; 20 cin >> n; 21 int ma = 0; 22 for(int i = 1; i <= n; i++) { 23 cin >> num[i]; 24 if(num[i] > ma) ma = num[i]; 25 } 26 int tol = 0; 27 for(int i = 1; i <= n; i++) { 28 tol += ma - num[i]; 29 } 30 cout << tol << endl; 31 return 0; 32 }