ZOJ-1236 Eat or Not to Eat?
来源:互联网 发布:mac pro散热在哪 编辑:程序博客网 时间:2024/05/01 22:34
Eat or Not to Eat?
Time Limit: 10 Seconds MemoryLimit: 32768 KB
A young farmer hasN cows, but they produced really really a very very small amount of milk. Johncannot live on the milk they made, so he's planning to eat some of the 'worst'cows to get rid of hunger. Each day, John chooses the cow that produces theLEAST amount of milk on that day and eat them. If there are more than one cowwith minimal milk, John will be puzzled and will not eat any of them (Yeah!That's GREAT!!).
The i-th cow has acycle of production Ti. That means, if it produces L unit milk on one day, itwill also produce L unit after Ti days -- If it will not be eaten during theseday :-). Though John is not a clever man, he doubts whether the cows will beeventually eaten up, so he asks for your help. Don't forget that he will offeryou some nice beef for that!
Input
The first line ofthe input contains a single integer T, indicating the number of test cases.(1<=T<=500) Each test case begins with an integer N(1<=N<=1000),the number of cows. In the following N lines, each line contains an integerTi(1<=Ti<=10), indicating the cycle of the i-th cow, then Ti integersMj(0<=Mj<=250) follow, indicating the amount of milk it can produce onthe j-th day.
Output
For each test casein the input, print a single line containing two integers C, D, indicating thenumber of cows that will NOT be eaten, and the number of days passed when thelast cow is eaten. If no cow is eaten, the second number should be 0.
Sample Input
1
4
4 7 1 2 9
1 2
2 7 1
1 2
Sample Output
2 6
#include <stdio.h>struct node { int T; int m[11]; int kill;};int test(struct node *, int, int, int);int main(){ int T, n, i, j, f; int min, count, temp, total, day, circul; struct node cow[1001]; scanf("%d", &T); while(T--) { scanf("%d", &n); for(i = 0; i < n; i++) { scanf("%d", &cow[i].T); cow[i].kill = 0; for(j = 0; j < cow[i].T; j++) {scanf("%d", &cow[i].m[j]); } } f = 1; i = 0; total = n; circul = 0; while(f) { min = 1000; count = 0; for(j = 0; j < n; j++) {if(!cow[j].kill) { if(cow[j].m[i % cow[j].T] < min) { min = cow[j].m[i % cow[j].T]; temp = j; count = 1; } else if(cow[j].m[i % cow[j].T] == min) { count++; }} } if(count == 1) {cow[temp].kill = 1;total--;circul = 0; } else {circul++; } if(circul >= 500) {f = 0;break; } i++; } if(total == n) { day = 0; } else { day = i + 1 - circul; } printf("%d %d\n", total, day); }}
- ZOJ-1236 Eat or Not to Eat?
- 10273 - Eat or Not to Eat?
- uva 10273 Eat or Not to Eat?
- UVa10273 Eat or Not to Eat?
- UVA - 10273 Eat or Not to Eat?
- UVA 10273 Eat or Not to Eat?
- uva 10273 - Eat or Not to Eat?(暴力枚举)
- UVA 10273 - Eat or Not to Eat?(暴力)
- UVA10273 - Eat or Not to Eat?(暴力)
- UVA - 10273 Eat or Not to Eat? 暴力
- Eat or Not to Eat? - UVa 10273 暴力
- eat
- eat
- eat out or eat in 吃货英语
- rest-work-eat-study-rest-work-eat or rest-rest-work-work-eat-eat..
- 1587. Eat or Be Eaten
- Eat at home or restaurant
- 3991. Eat or Study toj
- ZOJ-2240 Run Length Encoding
- 国际C语言混乱代码大赛优胜作品详解之“A clock in one line
- PostGis判断两个地理信息的距离是否小于某个值
- 初学 spring mvc 1
- iotop命令无法使用的解决办法
- ZOJ-1236 Eat or Not to Eat?
- 【转帖】C#中Property和Attribute的区别
- winform实现F1帮助和下拉菜单中的帮助文档
- 常见编译错误
- extjs4.2:点击第一个grid切换第二个grid的store
- 关于缺少各种framework出现的错误累结
- JAVA中的泛型和C++中的模板不一样
- CUDA笔记之一:实践编程篇
- CUDA笔记之二:硬件与拓扑原理篇