【題解】Codeforces 1392F. Omkar and Landslide

【題目敘述】http://codeforces.com/contest/1392/problem/F

#include <iostream>
using namespace std;
 
long long n, h, tot;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> h;
        tot += h;
        tot -= i;
    }
    long long tmp = tot/n;
    tot -= tmp*n;
    for (int i = 0; i < tot; i++){
        cout << i+tmp+1 << " ";
    }
    for (int i = tot; i < n; i++){
        cout << i+tmp << " ";
    }
}
分享本文 Share with friends