QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754381 | #7942. $K$ Subsequences | arashMLG# | WA | 1ms | 5692kb | C++17 | 1.5kb | 2024-11-16 14:55:50 | 2024-11-16 14:55:53 |
Judging History
answer
#include<bits/stdc++.h>
#ifdef LOCAL
#include "Essentials/algo/debug.h"
#else
#define debug(...) 69
#define debugArr(...) 69
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N =5e5 + 23;
const ll inf = 1e18;
#define F first
#define S second
#define pb push_back
#define kill(x) cout<<x<<endl, exit(0);
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lc (v << 1)
#define rc ((v<<1) |1)
int n,k;
int val[N];
int a[N];
set<pii> st;
void solve() {
cin>>n>>k;
for(int i = 1; i<= n ; i++) {
cin>>a[i];
}
st.clear();
for(int i = 1;i <= k; i++) {
st.insert({0,i});
}
for(int i =1; i<= n ;i ++) {
debug(st);
if(a[i] == 1) {
int x = st.begin()->F;
int id= st.begin()->S;
st.erase(*st.begin());
val[i] = id;
x++;
st.insert({x,id});
} else {
int x= st.begin()->F;
int id = st.begin()->S;
st.erase(*st.rbegin());
val[i] = id;
x = max(x-1,0);
st.insert({x,id});
}
cout<<val[i] << ' ';
}
cout<<'\n';
}
int32_t main() {
cin.tie(nullptr)->sync_with_stdio(false);
int testcase= 1;
cin>>testcase;
for(int tcase = 1; tcase <= testcase; tcase ++) {
#ifdef LOCAL
cout<<"\n------------------\n" << "Test case: " << tcase<< endl;
#endif
solve();
#ifdef LOCAL
cout<<endl;
#endif
}
return 0;
}
// Jumpsuit, Jumpsuit cover me!
// Jumpsuit, Jumpsuit cover me!
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5692kb
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 2 2 1 1 1 1 1 2 3 1 2 3 1 1 2 3 1 2 2 2 2 2 2 1 2 3 4 1 1 1 1 1 1 1 1
result:
wrong answer Jury found better answer than participant (test case 2)