-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE_Blackslex_and_Girls.cpp
More file actions
62 lines (51 loc) · 1.02 KB
/
E_Blackslex_and_Girls.cpp
File metadata and controls
62 lines (51 loc) · 1.02 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
#include <bits/stdc++.h>
using namespace std;
// First you make it work, then you can always make it beautiful
#define int long long
void solve() {
int n, x, y;
cin >> n >> x >> y;
vector<int> p(n);
string s;
cin >> s;
int sum = 0;
for(int i=0;i<n;i++) {
cin >> p[i];
sum += p[i];
}
if(sum > x + y) {
cout << "NO\n";
return;
}
int s1 = 0, s2 = 0;
for(int i=0;i<n;i++) {
int val = (p[i] / 2) + 1;
if(s[i] == '0') {
s1 += val;
}
else {
s2 += val;
}
}
if(s1 > x || s2 > y) {
cout << "NO\n";
return;
}
int cnt = count(s.begin(), s.end(), '0');
if((cnt == 0 && y < x + n) || (cnt == n && x < y + n)) {
cout << "NO\n";
return;
}
cout << "YES\n";
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int _;
cin >> _;
while (_-->0) {
solve();
}
return 0;
}