-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# 题目描述 | ||
|
||
$Jinggangshan~University$ ACM 算法实验室 23 届招新选拔赛于今日正式举行啦! | ||
|
||
现有 $n$ 名萌新正在教室里参加选拔赛,他们将在比赛中面临 $7$ 道编程题的考验,每道编程题都有相应的分值,这 $7$ 道编程题的得分总和构成该参赛者的最终成绩 $score~(0 \leq score \leq {10}^6)$。 | ||
|
||
Nostalgia 是只好胜心极强的老鸟,他偷偷准备了 $m$ 份最终成绩,由于他马上要去赴一场很重要的约会,来不及计算这 $m$ 份最终成绩在萌新们当中的排名。作为 Nostalgia 的好朋友,请你在比赛结束之前帮他编写一个程序,计算出他的这 $m$ 份最终成绩中的每一份成绩在萌新们当中的排名。第 $i$ 份成绩的排名 $=$ 最终成绩大于第 $i$ 份成绩的萌新的数量 $+1$。 | ||
|
||
# 输入格式 | ||
|
||
第一行,两个整数 $n, m$。 | ||
|
||
第二行,$n$ 个整数 $a_i$,表示第 $i$ 位萌新的最终成绩。 | ||
|
||
第三行,$m$ 个整数 $b_i$,表示第 $i$ 份 Nostalgia 的最终成绩。 | ||
|
||
# 输出格式 | ||
|
||
一行,$m$ 个用空格间隔的整数 $rank_i$,表示 Nostalgia 的第 $i$ 份最终成绩在萌新当中的排名。 | ||
|
||
# 输入输出样例 | ||
|
||
```input1 | ||
6 7 | ||
1 1 4 5 1 4 | ||
1 9 1 9 8 1 0 | ||
``` | ||
|
||
```output1 | ||
4 1 4 1 1 4 7 | ||
``` | ||
|
||
# 说明/提示 | ||
|
||
【样例解释】: | ||
|
||
Nostalgia 的 $1$ 份成绩为 $1$,在萌新当中排第 $4$ 名; | ||
|
||
Nostalgia 的 $2$ 份成绩为 $9$,在萌新当中排第 $1$ 名; | ||
|
||
Nostalgia 的 $3$ 份成绩为 $1$,在萌新当中排第 $4$ 名; | ||
|
||
Nostalgia 的 $4$ 份成绩为 $9$,在萌新当中排第 $1$ 名; | ||
|
||
Nostalgia 的 $5$ 份成绩为 $8$,在萌新当中排第 $1$ 名; | ||
|
||
Nostalgia 的 $6$ 份成绩为 $1$,在萌新当中排第 $4$ 名; | ||
|
||
Nostalgia 的 $7$ 份成绩为 $0$,在萌新当中排第 $7$ 名; | ||
|
||
故最终答案为 $4~1~4~1~1~4~7$。 | ||
|
||
【数据范围】 | ||
|
||
对于 $50 \%$ 的测试用例,$1 \leq n, m \leq {10}^3$。 | ||
|
||
对于 $100 \%$ 的测试用例,$1 \leq n, m \leq {10}^5$。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from cyaron import * | ||
|
||
CASES = 10 | ||
|
||
for _t in range(1, CASES + 1): | ||
io = IO(f"{_t}.in") | ||
# ============================== | ||
if _t <= 5: | ||
n, m = 1000, 1000 | ||
score = 100 | ||
io.input_writeln(n, m) | ||
for _ in range(n): | ||
io.input_write(f"{randint(0, score)} ") | ||
io.input_write('\n') | ||
for _ in range(m): | ||
io.input_write(f"{randint(0, score)} ") | ||
else: | ||
n, m = 100000, 100000 | ||
score = 1000000 | ||
io.input_writeln(n, m) | ||
for _ in range(n): | ||
io.input_write(f"{randint(0, score)} ") | ||
io.input_write('\n') | ||
for _ in range(m): | ||
io.input_write(f"{randint(0, score)} ") | ||
# ============================== | ||
io.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <iostream> | ||
#include <algorithm> | ||
#include <vector> | ||
using namespace std; | ||
int main() | ||
{ | ||
ios::sync_with_stdio(false); | ||
cin.tie(nullptr); | ||
int n, m; | ||
cin >> n >> m; | ||
vector<int> v(n); | ||
for(auto &it : v) cin >> it; | ||
sort(v.begin(), v.end()); | ||
while(m--) { | ||
int x; | ||
cin >> x; | ||
cout << n - (upper_bound(v.begin(), v.end(), x) - v.begin()) + 1 << ' '; | ||
} | ||
return 0; | ||
} |