/ nth233 / 讨论 / 题解 /

P1000[P1123] 解题报告

留坑待填

#include <cstdio>
#include <iostream>
#include <cmath>
#define MAXN 10010

int n;
int decks[MAXN];

bool is_valid(int x) {
    return x >= 0 && x < n;
}

int main() {
    scanf("%d", &n);
    int sum = 0;
    for(int i = 0;i < n;++i) {
        scanf("%d", decks+i);
        sum += decks[i];
    }
    int ave = sum / n;
    int cnt = 0;
    for(int i = 0;i < n - 1;++i) {
        decks[i+1] += decks[i] - ave;
        cnt += abs(decks[i] - ave) > 0 ? 1 : 0;
    }
    printf("%d", cnt);
    return 0;
}

0 条评论

目前还没有评论...