-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1480B.cpp
More file actions
43 lines (42 loc) · 698 Bytes
/
1480B.cpp
File metadata and controls
43 lines (42 loc) · 698 Bytes
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
#include<bits/stdc++.h>
using namespace std;
void solve()
{
int A,B,N;
cin>>A>>B>>N;
//bool t=true;
vector<pair<int,int>> arr(N);
for(int i=0;i<N;i++)cin>>arr[i].first;
for(int i=0;i<N;i++)cin>>arr[i].second;
sort(arr.begin(),arr.end());
int i=0;
while(i<N)
{
int moves_to_kill_monster=(arr[i].second+A-1)/A;
int moves_to_kill_Hero=(B+arr[i].first-1)/arr[i].first;
if(moves_to_kill_monster>moves_to_kill_Hero){
cout<<"No"<<endl;
return;
}
B-=moves_to_kill_monster*arr[i].first;
i++;
if(B<=0)
{
break;
}
}
if(i==N)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
}
signed main()
{
int t;
cin>>t;
while(t--)
{
solve();
}
return 0;
}