QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#707779 | #7942. $K$ Subsequences | bilbo_b# | WA | 21ms | 3632kb | C++17 | 1.2kb | 2024-11-03 17:30:22 | 2024-11-03 17:30:23 |
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({t.x - 1, t.y});
}
}
}
for (auto i : ans) {
cout << i << " ";
}
cout << '\n';
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3632kb
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 3 1 2 3 1 2 3 4 4 3 2 1 1 2 3 4
result:
ok Correct (5 test cases)
Test #2:
score: -100
Wrong Answer
time: 21ms
memory: 3536kb
input:
18434 10 1 -1 1 1 -1 -1 1 -1 -1 1 1 10 2 -1 -1 -1 1 1 -1 1 1 1 1 10 2 1 -1 -1 -1 -1 1 1 -1 1 1 10 7 1 1 -1 1 -1 1 1 -1 -1 1 9 1 -1 1 -1 1 1 -1 1 -1 1 8 1 -1 -1 -1 -1 1 1 -1 -1 10 3 -1 -1 -1 1 1 1 1 -1 -1 -1 9 1 1 -1 -1 1 -1 -1 -1 -1 -1 10 10 -1 1 1 1 1 1 1 1 1 1 10 4 -1 1 -1 1 -1 1 1 -1 1 1 9 3 1 1 ...
output:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 1 2 1 1 1 1 1 1 2 1 2 1 1 1 2 2 3 3 4 5 5 4 6 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 1 1 3 2 1 1 1 1 1 1 1 1 1 1 1 2 3 4 5 6 7 8 9 1 1 1 2 2 3 4 4 1 2 1 2 2 1 3 3 1 1 3 1 2 2 3 4 2 4 4 1 1 2 3 4 5 6 7 7 7 1 1 1 2 2 2 3 4 4 1 1 1 1 1 1 1 1 1 1 2...
result:
wrong answer Jury found better answer than participant (test case 3)