AT_abc466_b.Representative Balls

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

There are NN balls.

The color of the ii-th ball is CiC_i, and its size is SiS_i. Here, the colors are represented by integers 1,2,…,M1, 2, \ldots, M.

For k=1,2,…,Mk = 1, 2, \ldots, M, output the maximum size of a ball of color kk, or -1 if there is no ball of color kk.

有 NN 个球。

第 ii 个球的颜色为 CiC_i,大小为 SiS_i。其中,颜色用整数 1,2,…,M1, 2, \ldots, M 表示。

对于 k=1,2,…,Mk = 1, 2, \ldots, M,输出颜色为 kk 的球的最大大小;若不存在颜色为 kk 的球,则输出 -1。

输入格式

The input is given from Standard Input in the following format:

NN MM
C1C_1 S1S_1
C2C_2 S2S_2
⋮\vdots
CNC_N SNS_N

输入从标准输入中按以下格式给出:

NN MM
C1C_1 S1S_1
C2C_2 S2S_2
⋮\vdots
CNC_N SNS_N

输出格式

In the order k=1,2,…,Mk = 1, 2, \ldots, M, output the maximum size of a ball of color kk if such a ball exists, or -1 otherwise, separated by spaces.

按顺序 k=1,2,…,Mk = 1, 2, \ldots, M,输出颜色为 kk 的球的最大尺寸(若存在这样的球),否则输出 -1,各结果以空格分隔。

输入输出样例

  • 输入#1

    4 5
    1 3
    2 10
    1 7
    4 9

    输出#1

    7 10 -1 9 -1
  • 输入#2

    5 5
    2 6
    5 12
    5 2
    5 9
    2 7

    输出#2

    -1 7 -1 -1 12

说明/提示

Sample 1 Explanation:
The maximum size of a ball of color 11 is 77, that of a ball of color 22 is 1010, and that of a ball of color 44 is 99.

There is no ball of color 33 or color 55.

Constraints

  • 1≤N,M≤1001 \leq N, M \leq 100
  • 1≤Ci≤M1 \leq C_i \leq M
  • 1≤Si≤1001 \leq S_i \leq 100
  • All input values are integers.

样例 1 解释:
颜色为 11 的球的最大尺寸为 77,颜色为 22 的球的最大尺寸为 1010,颜色为 44 的球的最大尺寸为 99。

不存在颜色为 33 或 55 的球。

约束条件

  • 1≤N,M≤1001 \leq N, M \leq 100
  • 1≤Ci≤M1 \leq C_i \leq M
  • 1≤Si≤1001 \leq S_i \leq 100
  • 所有输入值均为整数。

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

首页