P7072 100pts 桶排序
This commit is contained in:
LittleSheep 2024-10-15 21:13:27 +08:00
parent 1bb46a2ec5
commit 8fc5fa15dd
2 changed files with 27 additions and 1 deletions

View File

@ -27,4 +27,5 @@ add_executable(Playground
insert-sort/main.cc
csp-decode/main.cc
palin/main.cc
csp-backpack/main.cc)
csp-backpack/main.cc
csp-awarding/main.cc)

25
csp-awarding/main.cc Normal file
View File

@ -0,0 +1,25 @@
#include <iostream>
#include <algorithm>
using namespace std;
int bkt[1005];
int main() {
int n, w;
cin >> n >> w;
for (int i = 0; i < n; i++) {
int ele;
cin >> ele;
bkt[ele]++;
int tot = 0;
for (int j = 600; j >= 0; j--) {
tot += bkt[j];
if (tot >= max(1, (i + 1) * w / 100)) {
printf("%d ", j);
break;
}
}
}
}