A1305 | [COCI-2013_2014-contest5]#1 DOMINE
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko has a chessboard with N rows and just three columns. Slavica has written an integer on each field. Mirko has K dominoes at his disposal, their dimensions being 2x1, and has to arrange all of them on the board without overlapping, in a way that each domino covers exactly two fields of the board. He can rotate the dominoes as he pleases.
Help Mirko cover the largest sum of numbers possible with the dominoes!
Help Mirko cover the largest sum of numbers possible with the dominoes!
输入格式
The first line of input contains the integer N (1 ≤ N ≤ 1000), the number of rows, and K (1 ≤ K ≤
1000), the number of dominoes available.
Each of the following N lines contains three integers written in the i th row of the board. All numbers will be lesser than 106 by absolute value.
1000), the number of dominoes available.
Each of the following N lines contains three integers written in the i th row of the board. All numbers will be lesser than 106 by absolute value.
输出格式
The first and only line of output must contain the maximal sum possible to cover with exactly K dominoes.
输入输出样例
输入 #1
5 3 2 1 -1 1 3 2 0 2 3 2 1 1 3 3 0
输出 #1
16
输入 #2
2 2 0 4 1 3 5 1
输出 #2
13
Clarification of the first example: It is optimal to place all dominoes horizontally and along the right
edge of the second row, right edge of the third row and along the left edge of the final row.
edge of the second row, right edge of the third row and along the left edge of the final row.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted