QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757568 | #9483. Maximize Array | PleaseHackme# | WA | 0ms | 3612kb | C++20 | 842b | 2024-11-17 10:42:28 | 2024-11-17 10:42:29 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = int64_t;
//#define int long long
void solve() {
int n, k;
std::cin >> n >> k;
std::vector<std::pair<int, int>> a;
for (int i = 1;i <= n; i ++) {
int x;
std::cin >> x;
a.push_back({x, i});
}
sort(a.begin(), a.end(), [&](auto p, auto q) {
if (p.first == q.first) {
return p.second < q.second;
}
return p.first > q.first;
});
std::vector<int> ans;
int cur = 0;
for (auto [val, p] : a) {
if (p < cur) continue;
if ((p - cur - 1) % k == 0) {
cur = p;
ans.push_back(val);
}
}
for (auto x : ans) std::cout << x << ' ';
}
signed main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int t;
t = 1;
//std::cin >> t;
while (t--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3536kb
input:
9 3 1 2 3 4 1 2 3 4 1
output:
4 4 1
result:
ok 3 tokens
Test #2:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
6 1 1 6 4 2 3 5
output:
6 5
result:
ok 2 tokens
Test #3:
score: 0
Accepted
time: 0ms
memory: 3612kb
input:
6 5 6 5 4 3 2 1
output:
6 5 4 3 2 1
result:
ok 6 tokens
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3568kb
input:
1392 5 915 798 656 1252 1170 691 1298 205 254 1334 622 1090 1081 617 365 477 362 1306 35 432 744 144 1277 259 80 410 317 983 916 1089 700 1030 135 156 1102 945 1021 63 251 1173 485 1261 1305 219 1190 151 142 288 795 984 1324 417 1235 1295 374 1091 434 596 553 1298 244 1179 115 767 973 315 603 180 10...
output:
1385 1329 1324 1304 1247 1228 1218 1210 990 834 770 145 79 38
result:
wrong answer 2nd words differ - expected: '1386', found: '1329'