欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF978F.Mentors
Mentors
CF978F · Mentors
- 难度:1500
- 标签:binary search、data structures、implementation
- 链接:https://codeforces.com/problemset/problem/978/F
- 时间限制:3 seconds 内存限制:256 megabytes
- 出现位置:Day27-阶段模拟6-S T1T2稳分卷
英文原题面
Statement
In BerSoft programmers work, the programmer is characterized by a skill . A programmer can be a mentor of a programmer if and only if the skill of the programmer is strictly greater than the skill of the programmer and programmers and are not in a quarrel. You are given the skills of each programmers and a list of pairs of the programmers, which are in a quarrel (pairs are unordered). For each programmer , find the number of programmers, for which the programmer can be a mentor.
Input
The first line contains two integers and , $0 \le k \le \min(2 \cdot 10^5, \frac{n \cdot (n - 1)}{2}))$ — total number of programmers and number of pairs of programmers which are in a quarrel. The second line contains a sequence of integers , where equals to the skill of the -th programmer. Each of the following lines contains two distinct integers , , — pair of programmers in a quarrel. The pairs are unordered, it means that if is in a quarrel with then is in a quarrel with . Guaranteed, that for each pair there are no other pairs and in the input.
Output
Print integers, the -th number should be equal to the number of programmers, for which the -th programmer can be a mentor. Programmers are numbered in the same order that their skills are given in the input.
样例
样例 1
输入:
4 2
10 4 10 15
1 2
4 3
输出:
0 0 1 2
样例 2
输入:
10 4
5 4 1 5 4 3 7 1 2 5
4 6
2 1
10 8
3 5
输出:
5 4 0 5 3 3 9 0 2 5
样例解释(英文原文)
In the first example, the first programmer can not be mentor of any other (because only the second programmer has a skill, lower than first programmer skill, but they are in a quarrel). The second programmer can not be mentor of any other programmer, because his skill is minimal among others. The third programmer can be a mentor of the second programmer. The fourth programmer can be a mentor of the first and of the second programmers. He can not be a mentor of the third programmer, because they are in a quarrel.
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |