codeforces 758 A

n 个数

找到最大的 

使得每个数都和最大的相等 

花费求和

#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<math.h>
#include<set>
#include<string>

using namespace std;
typedef long long LL;

#define inf  10000000000000
#define MAXN 100010

int co[MAXN];

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        int mx=-1;
        int ans=0;

        for(int i=0;i<n;i++)
        {
            scanf("%d",&co[i]);
            mx=max(mx,co[i]);
        }
        for(int i=0;i<n;i++)
        {
            ans=ans+mx-co[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

 

posted on 2017-02-22 13:57  HelloWorld!--By-MJY  阅读(117)  评论(0编辑  收藏  举报

导航