QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#448863#7942. $K$ Subsequenceskzxx00011WA 0ms3632kbC++14621b2024-06-20 10:17:542024-06-20 10:17:55

Judging History

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

  • [2024-06-20 10:17:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3632kb
  • [2024-06-20 10:17:54]
  • 提交

answer

#include<iostream>
using namespace std;
const int N=2e5+1;
int a[N];
int b[N];
int n,k;
int sum1,sum2;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		sum1=0,sum2=0;
		cin>>n>>k;   //k个盒子 
		for(int i=1;i<=n;i++)
		{
			cin>>a[i];
			if(a[i]==1) sum1++;   //sum1个1 
			else sum2++;          //sum2个挡板 
		}
		int fg=sum1/(k+sum2);  
		int cnt1=0;
		int js1=1;
		for(int i=1;i<=n;i++)
		{
			if(a[i]==1) 
			{
				cnt1++;
				if(cnt1>fg&&js1<k) js1++,cnt1=1;
				b[i]=js1;
			}
			else b[i]=k;
		 } 
		 for(int i=1;i<=n;i++) cout<<b[i]<<" ";
		 cout<<endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
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:

2 2 2 
2 2 2 2 
1 1 2 2 3 3 3 
1 2 3 3 3 3 3 3 3 3 
1 2 3 4 4 4 4 4 4 4 4 4 

result:

wrong answer Jury found better answer than participant (test case 2)