QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#264616 | #7678. The Game | qkm66666# | WA | 3ms | 3868kb | C++17 | 1.3kb | 2023-11-25 14:37:02 | 2023-11-25 14:37:02 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=5e5;
int T,n,m;
int A[maxn],B[maxn];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin>>T;
while(T--){
cin>>n>>m;
for(int i=1;i<=n;i++){
cin>>A[i];
}
sort(A+1,A+n+1);
for(int i=1;i<=m;i++){
cin>>B[i];
}
sort(B+1,B+m+1);
int cnt=0;
bool flag=true;
for(int i=0;i<m;i++){
if(A[n-i]>B[m-i]){
flag=false;
}
cnt=cnt+B[m-i]-A[n-i];
}
if(cnt>n-m){
flag=false;
}
cnt=n-m-cnt;
int tmp=0;
int tpp=0;
for(int i=1;i<=n;i++){
if(A[i]<B[1]-1) tmp++;
if(A[i]==B[1]-1) tpp++;
}
if(tmp+min((tpp+1)/2,n-m-cnt)<cnt){
flag=false;
}
if(flag){
printf("%d\n",n-m);
for(int i=1;i<=cnt;i++){
printf("%d ",A[i]);
}
for(int i=m-1;i>=0;i--){
for(int j=A[n-i];j<B[m-i];j++){
printf("%d ",j);
}
}
printf("\n");
}
else{
printf("-1\n");
}
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3808kb
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: 3ms
memory: 3868kb
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:
wrong answer Jury has answer but participant has not (test case 1198)