当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3578:Card Game

题目描述

Jack and Joe are playing a special card game in which each card has some points in three properties apo, bqu and cri. Jack has one card while Joe has the other N - 1 cards. Every round Joe picks one of his cards and compares it with Jack's card. The one has the more powerful card wins the round. The rule is as follows:

  • The card has more points in apo is more powerful.
  • If two cards have the same points in apo, the one has more points in bqu is more powerful.
  • If two cards have the same points in apo and bqu, one has more points in cri is more powerful.
  • If two cards have the same points in apo, bqu and cri, Jack's card is more powerful.

After the compare, Joe's card is discarded so that he can never use it any more.

To make the game more competitive, Jack and Joe are given m chances each to enhance the cards. For each time, Jack may add 1 point to either property of his card while Joe may add 1 point to bqu of one card and 1 point to cri of another.

Joe wants to know how many rounds he can win if they both plays optimally.

输入解释

Input consists several test case.

The first line of each test case is N (N ≤ 100000), the total number of cards.

The following N lines describe the cards. Each line contains three integers a, b, c (a, b, c ≤ 10000) which present the number of points in apo, bqu and cri of that card respectively. Jack has the first card.

The last of each test case is M (M ≤ 10000000), the number of chances to enhance cards.

The input ends with N = 0.

输出解释

For each test case, output how many rounds Joe can win.

输入样例
3
0 0 0
1 0 0
1 0 0
1
3
0 0 0
0 0 0
0 0 0
0
0
输出样例
2
0

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3578

最后修改于 2020-10-29T07:05:07+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536