CodeForces546B Soldier and Badges 解題報告
阿新 • • 發佈:2018-08-21
def max space efi codeforce col fine 報告 define
最近忙。。。先上代碼吧。。。有空繼續寫題解。。。
#include<cstdio> #include<queue> using namespace std; #define MAXN 3005 int n, ans, t, s; int nn; int a[MAXN * 2]; int main(){ scanf( "%d", &n ); for ( int i = 1; i <= n; ++i ) scanf( "%d", &t ), a[t]++, s += t, nn = max( nn, t ); t= 0; for ( int i = 1; i <= 6000; ++i ){ if ( t == 0 && i > nn ) break; if ( t > 0 && a[i] == 0 ) t--, ans += i; if ( a[i] > 1 ) t += a[i] - 1; if ( a[i] ) ans += i; } printf( "%d\n", ans - s ); return 0; }
CodeForces546B Soldier and Badges 解題報告