QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#668292#7678. The Gamei0streamWA 32ms5992kbC++141.1kb2024-10-23 13:22:032024-10-23 13:22:06

Judging History

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

  • [2024-10-23 13:22:06]
  • 评测
  • 测评结果:WA
  • 用时:32ms
  • 内存:5992kb
  • [2024-10-23 13:22:03]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N=3*1e5+100;

int n,m,t,T,succ,a[N],b[N],c[N];
ll p,s;

priority_queue<int,vector<int>,greater<int> > q1,q2;

int main(){
	scanf("%d",&T);
	while (T--){
		scanf("%d%d",&n,&m);
		t=0;p=0;s=0;
		while (!q1.empty()) q1.pop();
		while (!q2.empty()) q2.pop();
		for (int i=1;i<=n;i++){
			scanf("%d",&a[i]);
			q1.push(a[i]);
			if (i>=n-m+1) q2.push(a[i]),s+=a[i];
		}
		for (int i=1;i<=m;i++){
			scanf("%d",&b[i]);
			p+=b[i];
		}
		while (q1.size()-m > p-s){
			c[++t]=q1.top();q1.pop();
			q1.push(c[t]+1);q1.pop();
			if (c[t]+1>q2.top()){
				s+=c[t]+1-q2.top();
				q2.pop();
				q2.push(c[t]+1);
			}
		}
		if (q1.size()-m == p-s){
			sort(b+1,b+m+1);
			for (int i=1;i<=m;i++){
				a[i]=q2.top();
				q2.pop();
			}
			succ=1;
			for (int i=1;i<=m;i++){
				if (a[i]>b[i]) succ=0;
				while (a[i]<b[i]) c[++t]=a[i]++;
			}
			if (succ){
				printf("%d\n",n-m);
				for (int i=1;i<=t;i++) printf("%d ",c[i]);
				puts("");
			}else puts("-1");
		}else puts("-1");
	}
	return 0;
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3876kb

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: 0
Accepted
time: 2ms
memory: 5924kb

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
2 
-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:

ok ok (7056 test cases)

Test #3:

score: 0
Accepted
time: 3ms
memory: 3948kb

input:

5880
4 2
1 1 1 1
1 1
4 2
1 1 1 1
1 2
4 2
1 1 1 1
1 3
4 2
1 1 1 1
1 4
4 2
1 1 1 1
1 5
4 2
1 1 1 1
1 6
4 2
1 1 1 1
1 7
4 2
1 1 1 1
2 2
4 2
1 1 1 1
2 3
4 2
1 1 1 1
2 4
4 2
1 1 1 1
2 5
4 2
1 1 1 1
2 6
4 2
1 1 1 1
2 7
4 2
1 1 1 1
3 3
4 2
1 1 1 1
3 4
4 2
1 1 1 1
3 5
4 2
1 1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
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
2 3 4 
-1
-1
3
1 1 2 
3
1 2 3 
-1
-1
3
1 2 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
3 4 5 
-1
-1
3
1 1 3 
3
1 3 4 
-1
3
1 1 2 
3
1 2 3 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
3
1 1 4 
3
1...

result:

ok ok (5292 test cases)

Test #7:

score: 0
Accepted
time: 2ms
memory: 3944kb

input:

3234
5 1
1 1 1 1 1
1
5 1
1 1 1 1 1
2
5 1
1 1 1 1 1
3
5 1
1 1 1 1 1
4
5 1
1 1 1 1 1
5
5 1
1 1 1 1 1
6
5 1
1 1 1 1 1
7
5 1
1 1 1 1 2
1
5 1
1 1 1 1 2
2
5 1
1 1 1 1 2
3
5 1
1 1 1 1 2
4
5 1
1 1 1 1 2
5
5 1
1 1 1 1 2
6
5 1
1 1 1 1 2
7
5 1
1 1 1 1 3
1
5 1
1 1 1 1 3
2
5 1
1 1 1 1 3
3
5 1
1 1 1 1 3
4
5 1
1 1...

output:

-1
-1
4
1 1 1 2 
4
1 1 2 3 
4
1 2 3 4 
-1
-1
-1
-1
4
1 1 2 2 
4
1 1 2 3 
4
1 2 3 4 
4
2 3 4 5 
-1
-1
-1
-1
4
1 1 2 3 
4
1 1 3 4 
4
1 3 4 5 
4
3 4 5 6 
-1
-1
-1
4
1 1 2 3 
4
1 1 2 4 
4
1 1 4 5 
4
1 4 5 6 
-1
-1
-1
-1
4
1 1 2 3 
4
1 1 2 5 
4
1 1 5 6 
-1
-1
-1
-1
-1
4
1 1 2 3 
4
1 1 2 6 
-1
-1
-1
-1
-1...

result:

ok ok (3234 test cases)

Test #8:

score: 0
Accepted
time: 5ms
memory: 5844kb

input:

8820
5 4
1 1 1 1 1
1 1 1 1
5 4
1 1 1 1 1
1 1 1 2
5 4
1 1 1 1 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
-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:

ok ok (26460 test cases)

Test #10:

score: 0
Accepted
time: 28ms
memory: 5916kb

input:

50000
6 4
1 1 1 1 1 1
1 1 1 1
6 4
1 1 1 1 1 1
1 1 1 2
6 4
1 1 1 1 1 1
1 1 1 3
6 4
1 1 1 1 1 1
1 1 1 4
6 4
1 1 1 1 1 1
1 1 1 5
6 4
1 1 1 1 1 1
1 1 1 6
6 4
1 1 1 1 1 1
1 1 2 2
6 4
1 1 1 1 1 1
1 1 2 3
6 4
1 1 1 1 1 1
1 1 2 4
6 4
1 1 1 1 1 1
1 1 2 5
6 4
1 1 1 1 1 1
1 1 2 6
6 4
1 1 1 1 1 1
1 1 3 3
6 4
1 ...

output:

-1
-1
2
1 2 
-1
-1
-1
2
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:

ok ok (50000 test cases)

Test #11:

score: 0
Accepted
time: 14ms
memory: 5912kb

input:

25872
6 3
1 1 1 1 1 1
1 1 1
6 3
1 1 1 1 1 1
1 1 2
6 3
1 1 1 1 1 1
1 1 3
6 3
1 1 1 1 1 1
1 1 4
6 3
1 1 1 1 1 1
1 1 5
6 3
1 1 1 1 1 1
1 1 6
6 3
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2 3 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4
3 4 5 6 
-1
-1
4
1 1 1 3 
4
1 1 ...

result:

ok ok (25872 test cases)

Test #13:

score: 0
Accepted
time: 7ms
memory: 5936kb

input:

13728
6 1
1 1 1 1 1 1
1
6 1
1 1 1 1 1 1
2
6 1
1 1 1 1 1 1
3
6 1
1 1 1 1 1 1
4
6 1
1 1 1 1 1 1
5
6 1
1 1 1 1 1 1
6
6 1
1 1 1 1 1 1
7
6 1
1 1 1 1 1 1
8
6 1
1 1 1 1 1 2
1
6 1
1 1 1 1 1 2
2
6 1
1 1 1 1 1 2
3
6 1
1 1 1 1 1 2
4
6 1
1 1 1 1 1 2
5
6 1
1 1 1 1 1 2
6
6 1
1 1 1 1 1 2
7
6 1
1 1 1 1 1 2
8
6 1
1 ...

output:

-1
-1
5
1 1 1 2 2 
5
1 1 1 2 3 
5
1 1 2 3 4 
5
1 2 3 4 5 
-1
-1
-1
-1
5
1 1 1 2 2 
5
1 1 1 2 3 
5
1 1 2 3 4 
5
1 2 3 4 5 
5
2 3 4 5 6 
-1
-1
-1
-1
5
1 1 1 2 3 
5
1 1 1 3 4 
5
1 1 3 4 5 
5
1 3 4 5 6 
5
3 4 5 6 7 
-1
-1
-1
5
1 1 1 2 3 
5
1 1 1 2 4 
5
1 1 1 4 5 
5
1 1 4 5 6 
5
1 4 5 6 7 
-1
-1
-1
-1
5
...

result:

ok ok (13728 test cases)

Test #14:

score: 0
Accepted
time: 4ms
memory: 5916kb

input:

10080
7 6
1 1 1 1 1 1 1
1 1 1 1 1 1
7 6
1 1 1 1 1 1 1
1 1 1 1 1 2
7 6
1 1 1 1 1 1 1
1 1 1 1 1 3
7 6
1 1 1 1 1 1 1
1 1 1 1 1 4
7 6
1 1 1 1 1 1 1
1 1 1 1 2 2
7 6
1 1 1 1 1 1 1
1 1 1 1 2 3
7 6
1 1 1 1 1 1 1
1 1 1 1 2 4
7 6
1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1
-1
-1
-1
3
1 1 ...

result:

ok ok (23100 test cases)

Test #16:

score: 0
Accepted
time: 28ms
memory: 5912kb

input:

41580
7 5
1 1 1 1 1 1 1
1 1 1 1 1
7 5
1 1 1 1 1 1 1
1 1 1 1 2
7 5
1 1 1 1 1 1 1
1 1 1 1 3
7 5
1 1 1 1 1 1 1
1 1 1 1 4
7 5
1 1 1 1 1 1 1
1 1 1 1 5
7 5
1 1 1 1 1 1 1
1 1 1 2 2
7 5
1 1 1 1 1 1 1
1 1 1 2 3
7 5
1 1 1 1 1 1 1
1 1 1 2 4
7 5
1 1 1 1 1 1 1
1 1 1 2 5
7 5
1 1 1 1 1 1 1
1 1 1 3 3
7 5
1 1 1 1 1 ...

output:

-1
-1
2
1 2 
-1
-1
2
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:

ok ok (41580 test cases)

Test #17:

score: 0
Accepted
time: 7ms
memory: 3944kb

input:

11550
7 3
1 1 1 1 1 1 1
1 1 1
7 3
1 1 1 1 1 1 1
1 1 2
7 3
1 1 1 1 1 1 1
1 1 3
7 3
1 1 1 1 1 1 1
1 1 4
7 3
1 1 1 1 1 1 1
1 1 5
7 3
1 1 1 1 1 1 1
1 2 2
7 3
1 1 1 1 1 1 1
1 2 3
7 3
1 1 1 1 1 1 1
1 2 4
7 3
1 1 1 1 1 1 1
1 2 5
7 3
1 1 1 1 1 1 1
1 3 3
7 3
1 1 1 1 1 1 1
1 3 4
7 3
1 1 1 1 1 1 1
1 3 5
7 3
1 ...

output:

-1
-1
-1
-1
4
1 2 3 4 
-1
-1
4
1 1 2 3 
-1
4
1 2 1 2 
-1
-1
-1
-1
-1
4
1 1 1 1 
4
1 1 1 2 
-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
4
1 2 3 4 
-1
4
1 2 2 3 
-1
-1
-1
-1
-1
4
1 1 1 2 
4
1 1 2 3 
-1
4
1 1 2 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-...

result:

ok ok (11550 test cases)

Test #18:

score: 0
Accepted
time: 10ms
memory: 5860kb

input:

16632
7 2
1 1 1 1 1 1 1
1 1
7 2
1 1 1 1 1 1 1
1 2
7 2
1 1 1 1 1 1 1
1 3
7 2
1 1 1 1 1 1 1
1 4
7 2
1 1 1 1 1 1 1
1 5
7 2
1 1 1 1 1 1 1
1 6
7 2
1 1 1 1 1 1 1
2 2
7 2
1 1 1 1 1 1 1
2 3
7 2
1 1 1 1 1 1 1
2 4
7 2
1 1 1 1 1 1 1
2 5
7 2
1 1 1 1 1 1 1
2 6
7 2
1 1 1 1 1 1 1
3 3
7 2
1 1 1 1 1 1 1
3 4
7 2
1 1 ...

output:

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

result:

ok ok (16632 test cases)

Test #19:

score: 0
Accepted
time: 14ms
memory: 3944kb

input:

27456
7 1
1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
1 1 1 2 
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4
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
4
1 2 3 4 
-1
4
1 2 2 3 
-...

result:

ok ok (34650 test cases)

Test #21:

score: 0
Accepted
time: 12ms
memory: 5992kb

input:

17325
8 3
1 1 1 1 1 1 1 1
1 1 1
8 3
1 1 1 1 1 1 1 1
1 1 2
8 3
1 1 1 1 1 1 1 1
1 1 3
8 3
1 1 1 1 1 1 1 1
1 1 4
8 3
1 1 1 1 1 1 1 1
1 1 5
8 3
1 1 1 1 1 1 1 1
1 2 2
8 3
1 1 1 1 1 1 1 1
1 2 3
8 3
1 1 1 1 1 1 1 1
1 2 4
8 3
1 1 1 1 1 1 1 1
1 2 5
8 3
1 1 1 1 1 1 1 1
1 3 3
8 3
1 1 1 1 1 1 1 1
1 3 4
8 3
1 1 ...

output:

-1
-1
-1
-1
-1
-1
-1
-1
5
1 1 2 3 4 
-1
5
1 2 1 2 3 
-1
-1
-1
-1
-1
5
1 1 1 1 2 
5
1 1 1 2 3 
-1
5
1 1 2 1 2 
-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
5
1 2 2 3 4 
5
1 2 3 2 3 
-1
-1
-1
5
1 1 1 1 2 
5
1 1 1 2 3 
5
1 1 2 3 4 
5
1 1 1 2 2 
5
1 1 2 2 3 
-1
-1
-1
-1
...

result:

ok ok (17325 test cases)

Test #22:

score: 0
Accepted
time: 7ms
memory: 5924kb

input:

13860
8 6
1 1 1 1 1 1 1 1
1 1 1 1 1 1
8 6
1 1 1 1 1 1 1 1
1 1 1 1 1 2
8 6
1 1 1 1 1 1 1 1
1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1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
0

-1
-1
-1
...

result:

ok ok (225 test cases)

Test #24:

score: 0
Accepted
time: 10ms
memory: 5988kb

input:

15876
5 5
1 1 1 1 1
1 1 1 1 1
5 5
1 1 1 1 1
1 1 1 1 2
5 5
1 1 1 1 1
1 1 1 1 3
5 5
1 1 1 1 1
1 1 1 1 4
5 5
1 1 1 1 1
1 1 1 1 5
5 5
1 1 1 1 1
1 1 1 2 2
5 5
1 1 1 1 1
1 1 1 2 3
5 5
1 1 1 1 1
1 1 1 2 4
5 5
1 1 1 1 1
1 1 1 2 5
5 5
1 1 1 1 1
1 1 1 3 3
5 5
1 1 1 1 1
1 1 1 3 4
5 5
1 1 1 1 1
1 1 1 3 5
5 5
1 ...

output:

0

-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:

ok ok (15876 test cases)

Test #25:

score: -100
Wrong Answer
time: 32ms
memory: 5880kb

input:

6000
50 30
2 3 3 1 10 6 8 8 6 8 6 2 4 7 1 2 9 10 3 7 2 4 9 7 10 8 1 2 10 9 2 2 1 10 8 2 6 3 3 9 1 1 9 7 6 6 5 8 10 8
5 4 4 4 9 2 3 4 8 3 10 5 7 3 7 7 10 2 8 5 9 10 1 5 10 8 2 4 2 8
50 30
5 2 2 8 10 9 4 1 8 8 6 10 6 9 2 1 2 2 3 9 10 10 5 1 6 7 4 4 6 5 7 3 1 2 5 2 4 7 10 5 8 5 2 10 8 6 1 1 10 7
2 6 4 ...

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
...

result:

wrong answer Wrong answer, the final sequence does not equal to B (test case 128)