CF808F.Card Game
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 p__i, magic number c__i and level l__i. 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.
数字收藏卡牌游戏最近变得非常流行,因此沃瓦决定尝试其中一款。
沃瓦的收藏中有 n 张卡牌。每张卡牌由其力量值 pi、魔法数值 ci 和等级 li 刻画。沃瓦希望构建一副总力量值不小于 k 的卡组;但魔法数值可能使他无法实现这一目标——若两张卡牌的魔法数值之和为质数,则沃瓦不能将这两张卡同时放入卡组。此外,若某张卡牌的等级高于沃瓦角色的等级,则沃瓦无法使用该卡牌。
目前沃瓦角色的等级为 1。请帮助沃瓦确定他需要达到的最小等级,以便能够构建出满足所需总力量值的卡组。
输入格式
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: p__i, c__i and l__i (1 ≤ p__i ≤ 1000, 1 ≤ c__i ≤ 100000, 1 ≤ l__i ≤ n).
第一行包含两个整数 n 和 k(1≤n≤100,1≤k≤100000)。
接下来有 n 行,每行包含三个数字,表示对应的卡片:pi、ci 和 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.
如果沃瓦无法构建满足所需攻击力的卡组,则输出 -1。否则,输出沃瓦为构建该卡组所需达到的最低等级。
输入输出样例
输入#1
5 8 5 5 1 1 5 4 4 6 3 1 12 4 3 12 1
输出#1
4
输入#2
3 7 4 4 1 5 8 2 5 3 3
输出#2
2
输入解题思路,AI测评打分。不知道怎么写?