P3472 [POI2008]MAF-Mafia

    • 134通过
    • 477提交
  • 题目提供者 洛谷
  • 评测方式 云端评测
  • 标签 贪心 POI 2008 高性能
  • 难度 省选/NOI-
  • 时空限制 1000ms / 128MB

题解

  • 提示:收藏到任务计划后,可在首页查看。
  • 最新讨论 显示

    推荐的相关题目 显示

    题目描述

    Mob feud rages in Equatorial Byteotia. The mob bosses have come to the country's capital, Byteburg, to settle the dispute.

    Negotiations were very tense, and at one point the trigger-happy participants drew their guns.

    Each participant aims at another with a pistol.

    Should they go on a killing spree, the shooting will go in accordance with the following code of honour:

    the participants shoot in a certain order, and at any moment at most one of them is shooting, no shooter misses, his target dies instantly, hence he may not shoot afterwards, everyone shoots once, provided he had not been shot before he has a chance to shoot, no participant may change his first target of choice, even if the target is already dead (then the shot causes no further casualties).

    An undertaker watches from afar, as he usually does. After all, the mobsters have never failed to stimulate his business.

    He sees potential profit in the shooting, but he would like to know tight estimations. Precisely he would like to know the minimum and maximum possible death rate.

    The undertaker sees who aims at whom, but does not know the order of shooting.

    You are to write a programme that determines the numbers he is so keen to know.

    Task Write a programme that:

    reads from the standard input what target each mobster has chosen, determines the minimum and maximum number of casualties, writes out the result to the standard output.

    给定n个神枪手,每个神枪手瞄准一个人,以一定顺序开枪,问最少和最多死多少人

    输入输出格式

    输入格式:

    The first line of the standard input contains the number of participants ().

    They are numbered from to .

    The second line contains integers , separated by single spaces, .

    denotes the number of participant's target.

    Note that it is possible that for some (the nerves, you know).

    输出格式:

    Your programme should write out two integers separated by a single space in the first and only line of the standard output. These numbers should be, respectively, the minimum and maximum number of casualties resulting from the shooting.

    输入输出样例

    输入样例#1: 复制
    8
    2 3 2 2 6 7 8 5
    
    输出样例#1: 复制
    3 5
    
    提示
    标程仅供做题后或实在无思路时参考。
    请自觉、自律地使用该功能并请对自己的学习负责。
    如果发现恶意抄袭标程,将按照I类违反进行处理。