-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFFL.cpp
45 lines (44 loc) · 945 Bytes
/
FFL.cpp
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
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
int main() {
// your code goes here
int t;
cin >> t;
while(t--) {
int n,s;
cin >> n >> s;
vector<int> nums(n);
vector<int> type(n);
int min1 = INT_MAX;
int min0 = INT_MAX;
int count0 = 0,count1 = 0;
for (int i = 0;i < n;i++) {
cin >> nums[i];
}
for (int i = 0;i < n;i++) {
cin >> type[i];
}
for (int i = 0;i < n;i++) {
if (type[i] == 0) {
if(min0 > nums[i]) {
min0 = nums[i];
}
count0++;
} else {
if (min1 > nums[i]) {
min1 = nums[i];
}
count1++;
}
}
if (count1 == 0 || count0 == 0) {
cout << "no\n";
} else if ((s + min0 + min1) <= 100) {
cout << "yes\n";
} else {
cout << "no\n";
}
}
return 0;
}