QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#802616 | #9873. Last Chance: Threads of Despair | ucup-team3161# | WA | 1ms | 7864kb | C++20 | 776b | 2024-12-07 14:11:50 | 2024-12-07 14:11:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
const int N=1e6+5;
int T,n,m,s,s1,tp,o,a[N],b[N];
pair<int,int> z[N];
void slv()
{
scanf("%d %d",&n,&m);
tp=s=s1=0;
for(int i=1;i<=n;++i)
{
scanf("%d",&a[i]);
if(a[i]>1) --a[i],++s;
else if(!s1) --a[i],++s1;
z[++tp]={a[i],0};
}
s+=s1;
for(int i=1;i<=m;++i)
scanf("%d",&b[i]),z[++tp]={b[i],1};
sort(z+1,z+tp+1);
for(int i=1;i<=tp;++i) if(z[i].se) o=i;
for(int i=1,t=0;i<=o;++i)
{
s-=max(z[i].fi-t,0);
if(s<0) {puts("No");return;}
++t;
}
puts("Yes");
}
int main()
{
scanf("%d",&T);
while(T--) slv();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 7752kb
input:
3 3 2 1 1 4 2 6 3 2 1 1 4 2 7 2 1 100 100 2
output:
Yes No Yes
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 7864kb
input:
3 7 1 1 1 1 1 1 1 1 9 5 2 3 4 5 6 7 1 6 5 3 3 4 5 6 7 1 5 7
output:
No No Yes
result:
ok 3 token(s): yes count is 1, no count is 2
Test #3:
score: 0
Accepted
time: 1ms
memory: 7724kb
input:
4 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 2
output:
Yes Yes Yes No
result:
ok 4 token(s): yes count is 3, no count is 1
Test #4:
score: 0
Accepted
time: 1ms
memory: 7744kb
input:
18 1 2 1 1 1 1 2 1 2 1 1 2 1 1 3 1 2 1 2 2 1 2 1 3 2 1 2 1 3 3 1 2 2 1 1 1 2 2 1 2 1 2 2 1 3 1 2 2 2 2 1 2 2 2 3 1 2 2 3 3 1 2 3 1 1 1 2 3 1 2 1 2 3 1 3 1 2 3 2 2 1 2 3 3 2 1 2 3 3 3
output:
Yes Yes Yes Yes No No Yes Yes No No No No Yes No No No No No
result:
ok 18 token(s): yes count is 7, no count is 11
Test #5:
score: -100
Wrong Answer
time: 1ms
memory: 7792kb
input:
18 2 1 1 1 1 2 1 1 1 2 2 1 1 1 3 2 1 1 2 1 2 1 2 1 2 2 1 2 1 3 2 1 1 3 1 2 1 1 3 2 2 1 3 1 3 2 1 2 2 1 2 1 2 2 2 2 1 2 2 3 2 1 2 3 1 2 1 3 2 2 2 1 2 3 3 2 1 3 3 1 2 1 3 3 2 2 1 3 3 3
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes No No
result:
wrong answer expected NO, found YES [12th token]