'commit'
This commit is contained in:
27
TangDou/CSP-J/J2_2020/2_Bucket.cpp
Normal file
27
TangDou/CSP-J/J2_2020/2_Bucket.cpp
Normal file
@@ -0,0 +1,27 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int n, w;
|
||||
const int N = 610;
|
||||
int b[N];
|
||||
// 可以AC,原因:n*600
|
||||
int main() {
|
||||
cin >> n >> w;
|
||||
for (int i = 1; i <= n; i++) { // 在线性
|
||||
int x;
|
||||
cin >> x;
|
||||
|
||||
b[x]++; // 分值x,记数+1
|
||||
int cnt = max(1, i * w / 100); // 目前的获奖人数
|
||||
|
||||
int sum = 0;
|
||||
for (int j = 600; j >= 0; j--) { // 从后向前查找,找出分数由高到低的,并且,人数要够数的
|
||||
sum += b[j];
|
||||
if (sum >= cnt) {
|
||||
printf("%d ", j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user