'commit'
This commit is contained in:
19
TangDou/CSP-J/J2_2020/2_BruteForce.cpp
Normal file
19
TangDou/CSP-J/J2_2020/2_BruteForce.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
int n, w;
|
||||
const int N = 1e5 + 10;
|
||||
int a[N];
|
||||
|
||||
// 能通过一部分,50%左右,不能AC,原因是每次都排序O(n*n*logn)
|
||||
int main() {
|
||||
cin >> n >> w;
|
||||
for (int i = 1; i <= n; i++) { // 1e5 *600=6e7
|
||||
cin >> a[i]; // a[i]<=600
|
||||
int cnt = max(1, i * w / 100); // 1,2
|
||||
sort(a + 1, a + i + 1); // 从小到大排序
|
||||
printf("%d ", a[i - cnt + 1]); // 大的在后面
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user