From 8fc5fa15dd3b801a30093fd498fb79f5cec284ce Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 15 Oct 2024 21:13:27 +0800 Subject: [PATCH] =?UTF-8?q?:white=5Fcheck=5Fmark:=20P7072=20100pts=20?= =?UTF-8?q?=E6=A1=B6=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 3 ++- csp-awarding/main.cc | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 csp-awarding/main.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index 30f6d98..8585a85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/csp-awarding/main.cc b/csp-awarding/main.cc new file mode 100644 index 0000000..95a4711 --- /dev/null +++ b/csp-awarding/main.cc @@ -0,0 +1,25 @@ +#include +#include + +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; + } + } + } +} \ No newline at end of file