QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245475#7678. The Game8xinWA 4ms3508kbC++141.7kb2023-11-09 22:36:492023-11-09 22:36:49

Judging History

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

  • [2023-11-09 22:36:49]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3508kb
  • [2023-11-09 22:36:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 3e5 + 5;
const int inf = 1e9 + 5;
int a[N];
int b[N];
int c[N];
int d[N];
void solve(){
	int n,m;
	cin>>n>>m;
	int k=0;
	int kk=0;
	priority_queue<int,vector<int>,greater<int> > q;
	priority_queue<int,vector<int>,greater<int> > q1;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		q.push(a[i]);
		q1.push(a[i]);
		c[i]=0;
		d[i]=0;
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=m;++i){
		cin>>b[i];
	}
	sort(b+1,b+m+1);
	int kk1=0;
	for(int i=1;i<=n-m;++i){
		int num=q1.top();
		q1.pop();
		q1.push(num+1);
        q1.pop();
        if(q1.top()>b[1]){
//        	cout<<6<<endl;
			for(;i<=n-m;++i){
				++kk1;
				q.pop();
			}
        	break;
		}else {
			c[++k]=num;
			q.pop();
			q.push(num+1);
       		q.pop();
		}
	}
	int cnt=n-m;
	for(int i=1;i<=m;++i){
		int num=q.top();
		while(a[n-m+i]<num){
			d[++kk]=a[n-m+i];
			++a[n-m+i];
			--cnt;
		}
		q.pop();
	}
	int flag=1;
//	for(int i=1;i<=m;++i){
//		cout<<a[n-m+i]<<" ";
//	}
//	cout<<endl;
	for(int i=1;i<=m;++i){
		if(a[n-m+i]>b[i]){
			flag=0;
			break;
		}
		while(a[n-m+i]<b[i]){
			--cnt;
			--kk1;
			d[++kk]=a[n-m+i];
			++a[n-m+i];
		}
	}
	//cout<<flag<<endl;
	if(cnt<0)flag=0;
	int pdx=0;
	if(flag==1&&kk1<=0&&cnt<=k){
		cout<<n-m<<'\n';
		for(int i=1;i<=cnt;++i){
			cout<<c[i];
			++pdx;
			if(pdx==n-m)cout<<endl;
			else cout<<" ";
		}
		for(int i=1;i<=kk;++i){
			cout<<d[i];
			++pdx;
			if(pdx==n-m)cout<<endl;
			else cout<<" ";
		}
	}else{
		cout<<"-1\n";
	}
	return ;
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int t = 1;
	cin >> t;
	while(t--){
		solve();
	}
} 

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3508kb

input:

6
5 3
1 2 2 3 3
2 3 4
4 2
1 2 2 4
2 4
5 2
2 3 3 4 4
5 5
6 1
1 1 1 1 1 1
4
4 2
1 1 1 2
2 2
4 1
1 1 1 1
2

output:

2
1 3
-1
3
2 4 4
5
1 1 1 2 3
2
1 1
-1

result:

ok ok (6 test cases)

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3416kb

input:

7056
4 3
1 1 1 1
1 1 1
4 3
1 1 1 1
1 1 2
4 3
1 1 1 1
1 1 3
4 3
1 1 1 1
1 1 4
4 3
1 1 1 1
1 1 5
4 3
1 1 1 1
1 1 6
4 3
1 1 1 1
1 2 2
4 3
1 1 1 1
1 2 3
4 3
1 1 1 1
1 2 4
4 3
1 1 1 1
1 2 5
4 3
1 1 1 1
1 2 6
4 3
1 1 1 1
1 3 3
4 3
1 1 1 1
1 3 4
4 3
1 1 1 1
1 3 5
4 3
1 1 1 1
1 3 6
4 3
1 1 1 1
1 4 4
4 3
1 1...

output:

-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

wrong answer Jury has answer but participant has not (test case 59)