zoukankan      html  css  js  c++  java
  • 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.

    Input

    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: pici and li(1 ≤ pi ≤ 1000, 1 ≤ ci ≤ 100000, 1 ≤ li ≤ n).

    Output

    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.

    Examples
    input
    5 8
    5 5 1
    1 5 4
    4 6 3
    1 12 4
    3 12 1
    output
    4
    input
    3 7
    4 4 1
    5 8 2
    5 3 3
    output
    2

      题目大意是说,每个物品有三个属性p,c, l,当等级大于等于l才可已使用这个物品,选出一些物品使得两两的c之和为合数且p之和大于等于k,并且其中最大的l尽可能小,求这个最小需要达到的等级,如果无解,输出-1。

      通过最大值中的最小值可以想到二分答案,然后考虑用网络流得到最大的p值和。

      正确建图:2017.7.11 图论测试 T2

  • 相关阅读:
    C# 语音识别
    Android—监听器
    android-Activity
    Android小案例——简单图片浏览器
    针对Android 模拟器启动慢的问题
    emulator-arm.exe 已停止工作、 emulator-x86 已停止工作
    android模拟器启动没有拨号功能
    安装好android的adt以后重启eclipse,但是没有创建AVD的图标
    android环境搭建——工欲善其事,必先利其器 2
    SQL 中常见的系统存储过程
  • 原文地址:https://www.cnblogs.com/yyf0309/p/6937505.html
Copyright © 2011-2022 走看看