QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#806457 | #9873. Last Chance: Threads of Despair | Lonelyper | WA | 0ms | 3788kb | C++17 | 1.6kb | 2024-12-09 10:55:14 | 2024-12-09 10:55:15 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int>PII;
#define endl '\n'
#define x first
#define y second
const int N = 2e5 + 10;
const LL INF = 1e18, mod = 1e9 + 7;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());
int n, m;
void Lonelyper(){
cin >> n >> m;
vector<int> a(n + 1), b(m + 1);
for(int i = 1; i <= n; i ++) cin >> a[i];
for(int i = 1; i <= m; i ++) cin >> b[i];
sort(a.begin() + 1, a.end());
sort(b.begin() + 1, b.end());
int boom = 0;
bool flag = 0;
int sum = 0;
int pa = -1;
for(int i = 1; i <= n; i ++) {
if(a[i] != 1) {
pa = i;
break;
}
}
for(int i = 1; i <= n; i ++){
if(a[i] == 1 && flag == 0){
boom ++;
sum ++;
flag = 1;
}
else if(a[i] == 1) boom ++;
else if(a[i] != 1) sum ++;
}
// cout << boom << ' ' << sum << endl;
for(int i = 1; i <= m; i ++){
// cout << boom << ' ' << sum << endl;
if(sum + boom >= b[i]){
sum -= max(0, b[i] - boom);
boom ++;
}
else{
cout << "No" << endl;
return;
}
while(pa <= n && boom >= a[pa] - 1){
pa ++;
boom ++;
}
}
cout << "Yes" << endl;
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
cin >> t;
while(t --) {
Lonelyper();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3588kb
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: 3636kb
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: 0ms
memory: 3788kb
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: -100
Wrong Answer
time: 0ms
memory: 3632kb
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 Yes No Yes Yes No No No No Yes No No No No No
result:
wrong answer expected NO, found YES [5th token]