-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces_TheGreatHero.cpp
More file actions
73 lines (49 loc) · 1.44 KB
/
Codeforces_TheGreatHero.cpp
File metadata and controls
73 lines (49 loc) · 1.44 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
66
67
68
69
70
71
72
73
#include <bits/stdc++.h>
using namespace std;
int main() {
unsigned long long tCase;
cin >> tCase;
while(tCase--) {
unsigned long long atOfhero, heOfhero, nOfmons;
vector < unsigned long long > atOfmons;
vector < unsigned long long > heOfmons;
bool monsDead = false;
cin >> atOfhero >> heOfhero >> nOfmons;
for(unsigned long long i = 0; i < nOfmons; i++) {
unsigned long long atCarry;
cin >> atCarry;
atOfmons.push_back(atCarry);
}
for(unsigned long long i = 0; i < nOfmons; i++) {
unsigned long long heCarry;
cin >> heCarry;
heOfmons.push_back(heCarry);
}
for(unsigned long long i = 0; i < nOfmons; i++) {
if(heOfhero < atOfmons[i]) {
monsDead = false;
break;
}
unsigned long long attacks = heOfmons[i] / atOfhero;
if(heOfmons[i] % atOfhero != 0) {
attacks++;
}
heOfhero -= (attacks * atOfmons[i]);
heOfmons[i] -= ( atOfhero * attacks );
if(heOfmons[i] <= 0) {
monsDead = true;
}
else {
monsDead = false;
break;
}
}
if(monsDead && heOfhero > 0) {
cout << "YES" << endl;
}
else {
cout << "NO" << endl;
}
}
return 0;
}