https://matiji.net/exam/contest/contestdetail/55?type=4
const int N = 1e5 + 7;
int n, k, c[N];
void solve() {
long long ans = 0;
scanf("%d%d", &n, &k);
for (int i = 1; i <= n; ++ i) {
scanf("%d", &c[i]);
ans -= (long long)i * i * c[i];
}
priority_queue<int> heap;
for (int i = k + 1, cnt = 1; i <= n + k; ++ i) {
while (cnt <= n && cnt <= i) heap.push(c[cnt ++]);
ans += (long long)i * i * heap.top(); heap.pop();
}
printf("%lld\n", ans);
}
标签:cnt,小猫,exam,int,long,小度养
From: https://www.cnblogs.com/xjtfate/p/16632645.html