Educational Codeforces Round 21 Problem F (Codeforces 808F) - 最小割 - 二分答案
Digital collectible card games have become very popular recently. So Vova decided to try one of these.
Vova has n cards in his collection. Each of these cards is characterised by its power pi, magic number ci and level li. Vova wants to build a deck with total power not less than k, but magic numbers may not allow him to do so — Vova can't place two cards in a deck if the sum of the magic numbers written on these cards is a prime number. Also Vova cannot use a card if its level is greater than the level of Vova's character.
At the moment Vova's character's level is 1. Help Vova to determine the minimum level he needs to reach in order to build a deck with the required total power.
The first line contains two integers n and k (1 ≤ n ≤ 100, 1 ≤ k ≤ 100000).
Then n lines follow, each of these lines contains three numbers that represent the corresponding card: pi, ci and li(1 ≤ pi ≤ 1000, 1 ≤ ci ≤ 100000, 1 ≤ li ≤ n).
If Vova won't be able to build a deck with required power, print - 1. Otherwise print the minimum level Vova has to reach in order to build a deck.
5 8
5 5 1
1 5 4
4 6 3
1 12 4
3 12 1
4
3 7
4 4 1
5 8 2
5 3 3
2
题目大意是说,每个物品有三个属性p,c, l,当等级大于等于l才可已使用这个物品,选出一些物品使得两两的c之和为合数且p之和大于等于k,并且其中最大的l尽可能小,求这个最小需要达到的等级,如果无解,输出-1。
通过最大值中的最小值可以想到二分答案,然后考虑用网络流得到最大的p值和。
正确建图:2017.7.11 图论测试 T2
Educational Codeforces Round 21 Problem F (Codeforces 808F) - 最小割 - 二分答案的更多相关文章
- Educational Codeforces Round 21 Problem E(Codeforces 808E) - 动态规划 - 贪心
After several latest reforms many tourists are planning to visit Berland, and Berland people underst ...
- Educational Codeforces Round 21 Problem D(Codeforces 808D)
Vasya has an array a consisting of positive integer numbers. Vasya wants to divide this array into t ...
- Codeforces Round #202 (Div. 1) A. Mafia 推公式 + 二分答案
http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit p ...
- Educational Codeforces Round 21 Problem A - C
Problem A Lucky Year 题目传送门[here] 题目大意是说,只有一个数字非零的数是幸运的,给出一个数,求下一个幸运的数是多少. 这个幸运的数不是最高位的数字都是零,于是只跟最高位有 ...
- Educational Codeforces Round 21 D - Array Division (前缀和+二分)
传送门 题意 将n个数划分为两块,最多改变一个数的位置, 问能否使两块和相等 分析 因为我们最多只能移动一个数x,那么要么将该数往前移动,要么往后移动,一开始处理不需要移动的情况 那么遍历sum[i] ...
- Educational Codeforces Round 80 (Rated for Div. 2)D(二分答案,状压检验)
这题1<<M为255,可以logN二分答案后,N*M扫一遍表把N行数据转化为一个小于等于255的数字,再255^2检验答案(比扫一遍表复杂度低),复杂度约为N*M*logN #define ...
- Codeforces Round #402 (Div. 2) D. String Game(二分答案水题)
D. String Game time limit per test 2 seconds memory limit per test 512 megabytes input standard inpu ...
- Codeforces Round #402 (Div. 2) D题 【字符串二分答案+暴力】
D. String Game Little Nastya has a hobby, she likes to remove some letters from word, to obtain anot ...
- Educational Codeforces Round 21
Educational Codeforces Round 21 A. Lucky Year 个位数直接输出\(1\) 否则,假设\(n\)十进制最高位的值为\(s\),答案就是\(s-(n\mod ...
随机推荐
- Docker基本命令与使用 —— Docker容器(一)
一.容器的基本操作 1. 启动容器 docker run IMAGE [COMMAND] [ARG...] run 在新容器中执行命令 eg: docker run ubuntu echo 'Hell ...
- js 通过html()及text()方法获取并设置p标签的显示值
html()方法 此方法类似于JavaScript中的innerHTML属性,可以用来读取或者设置某个元素中的HTML内容.要获取某个元素的内容,可以这样: 复制代码 代码如下: var p_html ...
- 位运算求最值 学习笔记 (待补充QAQ)
没有什么前言?直接进入正题qwq 俩俩异或 求最值: 建trie树 O(n)枚举每个数找这个数的最值,每次反走就成,还可以剪枝一波(如果在某位已经小于ans显然可以直接return? void Ins ...
- Zero-Copy技术
概述 考虑这样一种常用的情形:你需要将静态内容(类似图片.文件)展示给用户.那么这个情形就意味着你需要先将静态内容从磁盘中拷贝出来放到一个内存buf中,然后将这个buf通过socket传输给用户,进而 ...
- 十天精通CSS3(5)
background-origin 设置元素背景图片的原始起始位置. 语法: background-origin : border-box | padding-box | content-box; 参 ...
- [py][mx]django自带后台系统使用
django的manytomany字段和后台搜索过滤功能 后台开发一般要求 后台要求能快速搭建, 主要精力放在前端用户系统开发上. 权限管理 少量样式 快速开发 django自带的后台手动注册模型 创 ...
- (转)Springboot 中filter 注入对象
问题:我建立一个全局拦截器,当然,这是测试的时候建立的,我把它命名为LogFilter,它继承了Filter,web应用启动的顺序是:listener->filter->servlet,而 ...
- [LeetCode] 258. Add Digits_Easy tag: Math
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit. ...
- web api 获取传过来的Json
public async void PostOrder(HttpRequestMessage request) { String responseBodyAsText = await request. ...
- toFixed()与toPrecision()
toFixed(n): 返回一个字符串,代表一个以定点表示法表示的数字. n在0~20之间 var g=1.023; var f=g.toFixed(2); f的值为:1.02, typeof ...