题解
2024-10-26 13:12:51
发布于:江苏
4阅读
0回复
0点赞
def main():
import sys
from math import floor
input = sys.stdin.read
data = input().splitlines()
# 读取第一行数据
n, m = map(int, data[0].strip().split())
# 读取选手的报名号和成绩
candidates = []
for i in range(1, n + 1):
k, s = map(int, data[i].strip().split())
candidates.append((k, s))
# 计算面试分数线
cut_off_index = floor(m * 1.5) # m * 150% 向下取整
# 对成绩进行排序,成绩越高的越靠前
sorted_candidates = sorted(candidates, key=lambda x: (-x[1], x[0])) # 按成绩降序,报名号升序
# 找到面试分数线
interview_cut_off_score = sorted_candidates[cut_off_index - 1][1]
# 筛选进入面试的选手
qualified_candidates = [(k, s) for k, s in sorted_candidates if s >= interview_cut_off_score]
# 输出结果
print(interview_cut_off_score, len(qualified_candidates))
for k, s in qualified_candidates:
print(k, s)
运行主程序
if name == "main":
main()
全部评论 1
#include <bits/stdc++.h>
using namespace std;
int main(){
cout << "666";
return 0;}
2024-10-26 来自 江苏
1#include <bits/stdc++.h>
using namespace std;
int main(){
cout << "666";
return 0;}
2024-10-26 来自 江苏
0
有帮助,赞一个