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

建议使用的浏览器:

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

3038:Flying Right

题目描述
Figuring that they cannot do worse than the humans have, Farmer John's cows have decided to start an airline. Being cows, they decide to cater to the heretofore-untapped market of cows as passengers. They plan to serve the cows who live along the western coast of Lake Michigan. Each morning, they will fly from the northern-most point of the coast southward towards Chicowgo, making many stops along the way. Each evening, they will fly back north to the northern-most point.

They need your help to decide which passengers to carry each day. Each of N (1 <= N <= 10,000) farms numbered 1..N along the coast contains an airport (Farm 1 is northern-most; farm N is southern-most). On this day, K (1 <= K <= 50,000) groups of cows wish to travel.Each group of cows wants to fly from a particular farm to another particular farm. The airline, if it wishes, is allowed to stop and pick up only part of a group. Cows that start a flight, however,must stay on the plane until they reach their destination.

Given the capacity C (1 <= C <= 100) of the airplane and the groups of cows that want to travel, determine the maximum number of cows that the airline can fly to their destination.
输入解释
* Line 1: Three space-separated integers: K, N, and C

* Lines 2..K+1: Each line contains three space-separated integers S, E, and M that specify a group of cows that wishes to travel. The M (1 <= M <= C) cows are currently at farm S and want to travel to farm E (S != E).
输出解释
* Line 1: The maximum number of cows that can be flown to their destination. This is the sum of the number of cows flown to their destination on the flight southward in the morning plus the number of cows flown to their destination on the flight northward in the evening.
输入样例
4 8 3
1 3 2
2 8 3
4 7 1
8 3 2
输出样例
6
提示
INPUT DETAILS:
Four groups of cows, eight farms, and three seats on the plane.

OUTPUT DETAILS:
In the morning, the flight takes 2 cows from 1->3, 1 cow from 2->8,and 1 cow from 4->7. In the evening, the flight takes 2 cows from 8->3.

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

源链接: POJ-3038

最后修改于 2020-10-29T06:50:59+00:00 由爬虫自动更新

共提交 0

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