logo AlgoBeat OnlineJudge
登录 注册

#101629. [BZOJ 1629] [Usaco2007 Demo]Cow Acrobats

内存限制:64 MiB 时间限制:5000 ms 标准输入输出
题目类型:传统 评测方式:文本比较
上传者: 匿名

题目描述

Farmer John's N (1

输入格式

  • Line 1: A single line with the integer N.

  • Lines 2..N+1: Line i+1 describes cow i with two space-separated integers, W_i and S_i.

输出格式

  • Line 1: A single integer, giving the largest risk of all the cows in any optimal ordering that minimizes the risk.

样例

样例输入

3
10 3
2 5
3 3

样例输出

2

OUTPUT DETAILS:

Put the cow with weight 10 on the bottom. She will carry the other
two cows, so the risk of her collapsing is 2+3-3=2. The other cows
have lower risk of collapsing.