-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathB.cpp
66 lines (62 loc) · 1.17 KB
/
B.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// LUOGU_RID: 155081305
#include <bits/stdc++.h>
using namespace std;
#define reg register
template <typename T>
inline void read(T &x){
char c;
do
c = getchar();
while(c == ' ' || c == '\n');
x = 0;
int w = 1;
if(c == '-'){
w = -1;
c = getchar();
}
do{
x = (x << 1) + (x << 3) + c - '0';
c = getchar();
}while (c != ' ' && c != '\n');
x *= w;
}
template <typename T>
inline void write(T arg){
T x = arg;
if(x < 0){
putchar('-');
x = -x;
}
if(x > 9)
write(x / 10);
putchar(x % 10 + '0');
}
const int MAX = 501;
int n,m,l,w,p,h[MAX],sum[MAX],mn[MAX],ans = 0;
signed main()
{
reg int i,j;
read(n);
for(i = 0;i < n;++i)
{
read(l);
read(w);
read(h[i]);
sum[i] = l + w << 1;
mn[i] = INT_MAX;
}
read(m);
for(i = 0;i < m;++i)
{
read(l);
read(w);
read(p);
for(j = 0;j < n;++j)
if(l >= h[j])
mn[j] = min(mn[j],(((sum[j] - 1) / w) / (l / h[j]) + 1) * p);
}
for(i = 0;i < n;++i)
ans += mn[i];
write(ans);
return 0;
}