Problem Description
Problem Analysis
Since the time and energy accumulated each day can always be consumed without being wasted, we can simply check whether the total available time and energy are sufficient.
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
| #include<stdio.h>
struct ClassData
{
int t;
int m;
} classList[120];
int main()
{
int T;
scanf("%d", &T);
while (T--)
{
int n;
scanf("%d", &n);
int a, b, d;
scanf("%d %d %d", &a, &b, &d);
for (int i = 0; i < n; i++)
{
scanf("%d %d", &classList[i].t, &classList[i].m);
}
int totalTime = a * d;
int totalMoney = b * d;
for (int i = 0; i < n; i++)
{
totalTime -= classList[i].t;
totalMoney -= classList[i].m;
}
if (totalTime >= 0 && totalMoney >= 0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
return 0;
}
|
Problem link: Thanksgiving KK Special — Here Comes the Exam - Problem Details - Problems - DidaOJ