标签:str hustoj space ace cpp cst ble continue return
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int a[50000];
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a, a + n);
int ans = 0;
for (int i = 0; i < n-1; i++)
if (a[i+1]-1 >= a[i]) continue;
else {
ans = ans + a[i] - a[i+1] + 1;
a[i+1] = a[i] + 1;
}
cout << ans << endl;
return 0;
}
标签:str hustoj space ace cpp cst ble continue return
原文地址:https://www.cnblogs.com/baoyihan/p/11068518.html