QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#478391 | #7942. $K$ Subsequences | embusca# | WA | 0ms | 3596kb | C++20 | 1.4kb | 2024-07-14 21:59:27 | 2024-07-14 21:59:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
cin.tie(0); ios:: sync_with_stdio(false);
int t; cin>>t;
for(int i=0;i<t;i++){
int n,k; cin>>n>>k;
vector<int> v;
int um=0, mn=0;
for(int i=0;i<n;i++){
int x; cin>>x;
v.push_back(x);
if(x==1) um++;
else mn++;
}
if(um==0){
for(int i=0;i<n;i++){
cout<<1<<" ";
}
cout<<'\n';
continue;
}
int l=1, r=n;
while(l<r){
int mid=l+(r-l)/2;
int nvu=um-(mid*k);
if(nvu<=0){
r=mid;
continue;
}
if(((mn)/mid)>=((nvu+(mid-1))/mid)){
r=mid;
}
else{
l=mid+1;
}
}
int c=l;
for(auto i: v){
if(i==1){
if(k){
cout<<k<<" ";
c--;
if(c==0 && k){
k--;
c=l;
}
}
else{
cout<<1<<' ';
}
}
else{
cout<<1<<' ';
}
}
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:
2 1 1 1 2 1 1 3 3 3 2 2 2 1 3 3 2 2 1 1 1 1 1 1 4 3 2 1 1 1 1 1 1 1 1 1
result:
wrong answer Jury found better answer than participant (test case 4)