A9287 | The Tournament
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The first line contains a pair of integers $n$ and $k$ ( $1<=k<=n+1$ ). The $i$ -th of the following $n$ lines contains two integers separated by a single space — $p_{i}$ and $e_{i}$ ( $0<=p_{i},e_{i}<=200000$ ).
The problem consists of three subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.
- In subproblem C1 (4 points), the constraint $1<=n<=15$ will hold.
- In subproblem C2 (4 points), the constraint $1<=n<=100$ will hold.
- In subproblem C3 (8 points), the constraint $1<=n<=200000$ will hold.
The problem consists of three subproblems. The subproblems have different constraints on the input. You will get some score for the correct submission of the subproblem. The description of the subproblems follows.
- In subproblem C1 (4 points), the constraint $1<=n<=15$ will hold.
- In subproblem C2 (4 points), the constraint $1<=n<=100$ will hold.
- In subproblem C3 (8 points), the constraint $1<=n<=200000$ will hold.
输入格式
Print a single number in a single line — the minimum amount of effort Manao needs to use to rank in the top $k$ . If no amount of effort can earn Manao such a rank, output number -1.
输出格式
Consider the first test case. At the time when Manao joins the tournament, there are three fighters. The first of them has 1 tournament point and the victory against him requires 1 unit of effort. The second contestant also has 1 tournament point, but Manao needs 4 units of effort to defeat him. The third contestant has 2 points and victory against him costs Manao 2 units of effort. Manao's goal is top be in top 2. The optimal decision is to win against fighters $1$ and $3$ , after which Manao, fighter $2$ , and fighter $3$ will all have 2 points. Manao will rank better than fighter $3$ and worse than fighter $2$ , thus finishing in second place.
Consider the second test case. Even if Manao wins against both opponents, he will still rank third.
Consider the second test case. Even if Manao wins against both opponents, he will still rank third.
输入输出样例
输入 #1
3 2 1 1 1 4 2 2
输出 #1
3
输入 #2
2 1 3 2 4 0
输出 #2
-1
输入 #3
5 2 2 10 2 10 1 1 3 1 3 1
输出 #3
12
Consider the first test case. At the time when Manao joins the tournament, there are three fighters. The first of them has 1 tournament point and the victory against him requires 1 unit of effort. The second contestant also has 1 tournament point, but Manao needs 4 units of effort to defeat him. The third contestant has 2 points and victory against him costs Manao 2 units of effort. Manao's goal is top be in top 2. The optimal decision is to win against fighters $1$ and $3$ , after which Manao, fighter $2$ , and fighter $3$ will all have 2 points. Manao will rank better than fighter $3$ and worse than fighter $2$ , thus finishing in second place.
Consider the second test case. Even if Manao wins against both opponents, he will still rank third.
Consider the second test case. Even if Manao wins against both opponents, he will still rank third.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted