-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2179e.cpp
More file actions
65 lines (58 loc) · 1.45 KB
/
2179e.cpp
File metadata and controls
65 lines (58 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while (t--) {
int n;
long long x, y;
cin >> n >> x >> y;
string s;
cin >> s;
vector<long long> p(n);
for (int i = 0; i < n; i++) cin >> p[i];
long long A_min_total = 0, B_min_total = 0;
long long p_total = 0;
for (int i = 0; i < n; i++) {
p_total += p[i];
if (s[i] == '0') {
A_min_total += p[i]/2 + 1;
} else {
B_min_total += p[i]/2 + 1;
}
}
if(p_total > x + y){
cout << "NO\n";
continue;
}
if (A_min_total > x || B_min_total > y) {
cout << "NO\n";
}
else {
bool has0 = false;
bool has1 = false;
for(char c : s){
if(c == '0')has0 = true;
if(c == '1')has1 = true;
}
if(has0 && has1){
cout << "YES\n";
}else if(has0){
if(x >= y + n){
cout << "YES\n";
}else{
cout << "NO\n";
}
}else{
if(y >= x + n){
cout << "YES\n";
}else{
cout << "NO\n";
}
}
}
}
return 0;
}