F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Food Problem

Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1810    Accepted Submission(s): 568


Problem Description
Few days before a game of orienteering, Bell came to a mathematician to solve a big problem. Bell is preparing the dessert for the game. There are several different types of desserts such as small cookies, little grasshoppers and tiny mantises. Every type of dessert may provide different amounts of energy, and they all take up different size of space.

Other than obtaining the desserts, Bell also needs to consider moving them to the game arena. Different trucks may carry different amounts of desserts in size and of course they have different costs. However, you may split a single dessert into several parts and put them on different trucks, then assemble the parts at the game arena. Note that a dessert does not provide any energy if some part of it is missing.

Bell wants to know how much would it cost at least to provide desserts of a total energy of $p$ (most of the desserts are not bought with money, so we assume obtaining the desserts costs no money, only the cost of transportation should be considered). Unfortunately the mathematician is having trouble with her stomach, so this problem is left to you.
 

Input
The first line of input contains a integer $T (T \leq 10)$ representing the number of test cases.

For each test case there are three integers $n, m, p$ on the first line $(1 \leq n \leq 200, 1 \leq m \leq 200, 0 \leq p \leq 50000)$, representing the number of different desserts, the number of different trucks and the least energy required respectively.

The $i-th$ of the $n$ following lines contains three integers $t_i, u_i, v_i (1 \leq t_i \leq 100, 1 \leq u_i \leq 100, 1 \leq v_i \leq 100)$ indicating that the $i-th$ dessert can provide $t_i$ energy, takes up space of size $u_i$ and that Bell can prepare at most $v_i$ of them.

On each of the next $m$ lines, there are also three integers $x_j , y_j , z_j (1 \leq x_j \leq 100, 1 \leq y_j \leq 100, 1 \leq z_j \leq 100)$ indicating that the $j-th$ truck can carry at most size of $x_j$ , hiring each one costs $y_j$ and that Bell can hire at most $z_j$ of them.
 

Output
For every test case output the minimum cost to provide the dessert of enough energy in the game arena if it is possible and its cost is no more than $50000$. Otherwise, output $TAT$ on the line instead.
 

Sample Input
4 1 1 7 14 2 1 1 2 2 1 1 10 10 10 1 5 7 2 5 3 34 1 4 1 9 4 2 5 3 3 1 3 3 5 3 2 3 4 5 6 7 5 5 3 8 1 1 1 1 2 1 1 1 1
 

Sample Output
4 14 12 TAT
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-25 09:47:47, Gzip enabled