CF808F.Card Game

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Digital collectible card games have become very popular recently. So Vova decided to try one of these.

Vova has nn cards in his collection. Each of these cards is characterised by its power pip_{i} , magic number cic_{i} and level lil_{i} . Vova wants to build a deck with total power not less than kk , 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 11 . 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 nn and kk ( 1<=n<=1001<=n<=100 , 1<=k<=1000001<=k<=100000 ).

Then nn lines follow, each of these lines contains three numbers that represent the corresponding card: pip_{i} , cic_{i} and lil_{i} ( 1<=pi<=10001<=p_{i}<=1000 , 1<=ci<=1000001<=c_{i}<=100000 , 1<=li<=n1<=l_{i}<=n ).

输出格式

If Vova won't be able to build a deck with required power, print 1-1 . Otherwise print the minimum level Vova has to reach in order to build a deck.

输入输出样例

  • 输入#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
    
首页