CF730A.Toda 2

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:512MB

AC君温馨提醒

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

题目描述

A group of n friends enjoys playing popular video game Toda 2. There is a rating system describing skill level of each player, initially the rating of the i-th friend is r__i.

The friends decided to take part in the championship as a team. But they should have equal ratings to be allowed to compose a single team consisting of all n friends. So the friends are faced with the problem: how to make all their ratings equal.

One way to change ratings is to willingly lose in some matches. Friends can form a party consisting of two to five (but not more than n) friends and play a match in the game. When the party loses, the rating of each of its members decreases by 1. A rating can't become negative, so r__i = 0 doesn't change after losing.

The friends can take part in multiple matches, each time making a party from any subset of friends (but remember about constraints on party size: from 2 to 5 members).

The friends want to make their ratings equal but as high as possible.

Help the friends develop a strategy of losing the matches so that all their ratings become equal and the resulting rating is maximum possible.

有 nn 位朋友喜欢玩一款流行的电子游戏《Toda 2》。每位玩家的技能水平由一个评级系统描述,初始时第 ii 位朋友的评分为 rir_i。

这些朋友决定以团队形式参加锦标赛。但为了能组成一个包含全部 nn 位朋友的单一团队,他们必须拥有相等的评级。因此,朋友们面临如下问题:如何使所有人的评级变得相等。

改变评级的一种方式是主动输掉若干场比赛。朋友们可以组成一支队伍(即“party”),队伍人数为 22 至 55 人(但不能超过 nn),然后进行一场比赛。当该队伍输掉比赛时,队伍中每位成员的评级均减少 11。评级不能变为负数,因此当 ri=0r_i = 0 时,再输掉比赛也不会改变其评级。

朋友们可以参加多场比赛,每次均可从所有朋友中任选一个子集组成队伍(但需始终满足队伍人数限制:22 至 55 人)。

朋友们希望在使所有评级相等的前提下,让最终的共同评级尽可能高。

请帮助朋友们设计一种输掉比赛的策略,使得所有人的评级最终相等,且该相等评级达到最大可能值。

输入格式

The first line contains a single integer n (2 ≤ n ≤ 100) — the number of friends.

The second line contains n non-negative integers _r_1, _r_2, ..., r__n (0 ≤ r__i ≤ 100), where r__i is the initial rating of the i-th friend.

第一行包含一个整数 nn(2≤n≤1002 \leq n \leq 100)——朋友的数量。

第二行包含 nn 个非负整数 r1,r2,…,rnr_1, r_2, \dots, r_n(0≤ri≤1000 \leq r_i \leq 100),其中 rir_i 表示第 ii 位朋友的初始评分。

输出格式

In the first line, print a single integer R — the final rating of each of the friends.

In the second line, print integer t — the number of matches the friends have to play. Each of the following t lines should contain n characters '0' or '1', where the j-th character of the i-th line is equal to:

  • '0', if friend j should not play in match i,
  • '1', if friend j should play in match i.

Each line should contain between two and five characters '1', inclusive.

The value t should not exceed 104, it is guaranteed that such solution exists.

Remember that you shouldn't minimize the value t, but you should maximize R. If there are multiple solutions, print any of them.

第一行输出一个整数 RR —— 每位朋友的最终评分。

第二行输出一个整数 tt —— 朋友们需要进行的比赛场数。接下来的 tt 行中,每行包含 nn 个字符,每个字符为 '0' 或 '1';其中第 ii 行的第 jj 个字符满足:

  • '0',表示第 jj 位朋友在第 ii 场比赛中不参赛;
  • '1',表示第 jj 位朋友在第 ii 场比赛中参赛。

每行中 '1' 的个数必须在 22 到 55 之间(含端点)。

tt 的值不得超过 10410^4,题目保证存在满足条件的解。

注意:你无需最小化 tt,但必须最大化 RR。若存在多个解,输出任意一个即可。

输入输出样例

  • 输入#1

    5
    4 5 1 7 4

    输出#1

    1
    8
    01010
    00011
    01010
    10010
    00011
    11000
    00011
    11000
  • 输入#2

    2
    1 2

    输出#2

    0
    2
    11
    11
  • 输入#3

    3
    1 1 1

    输出#3

    1
    0

输入解题思路,AI测评打分。不知道怎么写?

首页