QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#707663#7942. $K$ Subsequencesbilbo_b#WA 0ms3596kbC++171.2kb2024-11-03 16:56:372024-11-03 16:56:37

Judging History

你现在查看的是最新测评结果

  • [2024-11-03 16:56:37]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-11-03 16:56:37]
  • 提交

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)