QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#478391#7942. $K$ Subsequencesembusca#WA 0ms3596kbC++201.4kb2024-07-14 21:59:272024-07-14 21:59:27

Judging History

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

  • [2024-07-14 21:59:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-07-14 21:59:27]
  • 提交

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;
}

详细

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)