Files
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

27 lines
922 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
int n, w;
int b[610]; // b[x] 表示有几个选手成绩为 x
// 找第 k 名选手的成绩
int kth(int k) {
if (!k) k = 1; // 不足1人取1人
// 倒序枚举桶
for (int i = 600; ~i; i--) { // 分数上限不是很大,可枚举 ; ~i 表示>=0;
k -= b[i]; // 扣除掉此分数的学生数量
if (k <= 0) return i; // 扣无可扣,无需再扣
}
return 0; // 没找到,随便返回一个数。当然这句话永远不会执行。
}
int main() {
cin >> n >> w; // 人数,获奖率
for (int i = 1; i <= n; i++) {
int x;
cin >> x;
b[x]++; // 分数为x的同学多了一个
printf("%d ", kth(i * w / 100)); // 按计算公式计算,注意边界情况,获取当前第k名同学的成绩是多少
}
return 0;
}