QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#707663 | #7942. $K$ Subsequences | bilbo_b# | WA | 0ms | 3596kb | C++17 | 1.2kb | 2024-11-03 16:56:37 | 2024-11-03 16:56:37 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
using namespace std;
signed main() {
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int t;
cin >> t;
while(t--) {
int n, k, x;
cin >> n >> k;
vector<int> a(n);
vector<int> ans(n);
set<pair<int, int> > s;
for (int i = 0; i < n; ++i) {
cin >> x;
if (x == 1) {
if (s.size() < k) {
s.insert({1, s.size()});
ans[i] = s.size();
} else {
auto t = *s.begin();
s.erase(t);
ans[i] = t.y + 1;
s.insert({t.x + 1, t.y});
}
} else {
if (s.empty()) {
ans[i] = 1;
} else {
auto t = *s.rbegin();
s.erase(t);
ans[i] = t.y + 1;
s.insert({0, t.y});
}
}
}
for (auto i : ans) {
cout << i << " ";
}
cout << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3596kb
input:
5 3 2 1 -1 1 4 2 -1 1 1 -1 7 3 1 1 1 1 1 1 1 10 3 1 1 1 1 -1 -1 1 1 1 1 12 4 1 1 1 1 -1 -1 -1 -1 1 1 1 1
output:
1 1 2 1 1 2 2 1 2 3 1 2 3 1 1 2 3 1 1 3 1 3 1 2 1 2 3 4 4 3 2 1 1 2 3 4
result:
wrong answer Jury found better answer than participant (test case 4)