-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.java
65 lines (52 loc) · 2.67 KB
/
B.java
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
/*
/$$$$$ /$$$$$$ /$$ /$$ /$$$$$$
|__ $$ /$$__ $$| $$ | $$ /$$__ $$
| $$| $$ \ $$| $$ | $$| $$ \ $$
| $$| $$$$$$$$| $$ / $$/| $$$$$$$$
/$$ | $$| $$__ $$ \ $$ $$/ | $$__ $$
| $$ | $$| $$ | $$ \ $$$/ | $$ | $$
| $$$$$$/| $$ | $$ \ $/ | $$ | $$
\______/ |__/ |__/ \_/ |__/ |__/
/$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$ /$$$$$$$$ /$$$$$$$
| $$__ $$| $$__ $$ /$$__ $$ /$$__ $$| $$__ $$ /$$__ $$| $$$ /$$$| $$$ /$$$| $$_____/| $$__ $$
| $$ \ $$| $$ \ $$| $$ \ $$| $$ \__/| $$ \ $$| $$ \ $$| $$$$ /$$$$| $$$$ /$$$$| $$ | $$ \ $$
| $$$$$$$/| $$$$$$$/| $$ | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$ | $$$$$$$/
| $$____/ | $$__ $$| $$ | $$| $$|_ $$| $$__ $$| $$__ $$| $$ $$$| $$| $$ $$$| $$| $$__/ | $$__ $$
| $$ | $$ \ $$| $$ | $$| $$ \ $$| $$ \ $$| $$ | $$| $$\ $ | $$| $$\ $ | $$| $$ | $$ \ $$
| $$ | $$ | $$| $$$$$$/| $$$$$$/| $$ | $$| $$ | $$| $$ \/ | $$| $$ \/ | $$| $$$$$$$$| $$ | $$
|__/ |__/ |__/ \______/ \______/ |__/ |__/|__/ |__/|__/ |__/|__/ |__/|________/|__/ |__/
*/
import java.util.*;
import java.io.*;
import java.math.*;
public class cf{
public static void main(String[] args) throws IOException{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
Long A=sc.nextLong();
long B=sc.nextLong();
int n=sc.nextInt();
long a[]=new long[n];
long b[]=new long[n];
long max=0;
for(int i=0;i<n;i++){
a[i]=sc.nextLong();
max=Math.max(a[i],max);
}
for(int i=0;i<n;i++){
b[i]=sc.nextLong();
}
for(int i=0;i<n;i++){
long res=(b[i]+A-1)/A;
B-=(res*a[i]);
}
if(B+max<=0){
System.out.println("NO");
}
else{
System.out.println("YES");
}
}
}
}