AT_abc466_b.Representative Balls
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There are N balls.
The color of the i-th ball is Ci, and its size is Si. Here, the colors are represented by integers 1,2,…,M.
For k=1,2,…,M, output the maximum size of a ball of color k, or -1 if there is no ball of color k.
有 N 个球。
第 i 个球的颜色为 Ci,大小为 Si。其中,颜色用整数 1,2,…,M 表示。
对于 k=1,2,…,M,输出颜色为 k 的球的最大大小;若不存在颜色为 k 的球,则输出 -1。
输入格式
The input is given from Standard Input in the following format:
N M
C1 S1
C2 S2
⋮
CN SN
输入从标准输入中按以下格式给出:
N M
C1 S1
C2 S2
⋮
CN SN
输出格式
In the order k=1,2,…,M, output the maximum size of a ball of color k if such a ball exists, or -1 otherwise, separated by spaces.
按顺序 k=1,2,…,M,输出颜色为 k 的球的最大尺寸(若存在这样的球),否则输出 -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 1 is 7, that of a ball of color 2 is 10, and that of a ball of color 4 is 9.
There is no ball of color 3 or color 5.
Constraints
- 1≤N,M≤100
- 1≤Ci≤M
- 1≤Si≤100
- All input values are integers.
样例 1 解释:
颜色为 1 的球的最大尺寸为 7,颜色为 2 的球的最大尺寸为 10,颜色为 4 的球的最大尺寸为 9。
不存在颜色为 3 或 5 的球。
约束条件
- 1≤N,M≤100
- 1≤Ci≤M
- 1≤Si≤100
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?