This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#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;