第一行输入两个整数
,分别表示报名人数与计划录取人数。
接下来
行,每行输入两个整数
,分别为报名号与笔试成绩。报名号保证唯一。
第一行输出两个整数:面试分数线
与进入面试的人数
。
接下来
行,按排序顺序输出每位选手的报名号
与成绩
,每行两个整数,用空格分隔。
6 3 9848 90 6731 88 1422 95 7483 84 8805 95 4162 88
88 5 1422 95 8805 95 9848 90 4162 88 6731 88
计算:,第
名成绩为
,故分数线
;所有
的共有
人。
import java.util.Arrays;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int t = (int)(m * 1.5 ) ;
int[][] score = new int[n][2];
//存储所有人的分数
for (int i = 0; i < n; i++ ) {
score[i][0] = in.nextInt();
score[i][1] = in.nextInt();
}
// System.out.println(Arrays.toString(score));
int[] id = new int[n];
int[] po = new int[n];
//按分数排序分开存储
for (int j = 0; j < n; j++) {
int max = 0;
for (int i = 0; i < n; i++) {
max = Math.max(max, score[i][1]);
}
for (int i = 0; i < n; i++) {
if (score[i][1] == max) {
id[j] = score[i][0];
po[j] = score[i][1];
score[i][0] = 0;
score[i][1] = 0;
break;
}
}
// System.out.println(max);
}
// System.out.println(Arrays.toString(id));
// System.out.println(Arrays.toString(po));
//如果考号前大后小,交换顺序
for (int j = 0; j < n; j++) {
for (int i = 0; i < n - 1; i++) {
if (po[i] == po[i + 1] && id[i] > id[i + 1]) {
int temp = id[i];
id[i] = id[i + 1];
id[i + 1] = temp;
}
}
}
//计算分数线,这里一定要t-1,因为po的编号从0开始
int line = po[t-1];
//满足分数线的人计数
int count =0;
for(int i=0; i<n; i++){
if(po[i] >=line){
count++;
}
}
System.out.println(line+" "+count);
for (int i = 0; i < n; i++) {
if (po[i] >= line) {
System.out.println(id[i] + " " + po[i]);
}
}
}
} import java.util.*;
import java.io.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String[] line1 = bf.readLine().split(" ");
int n = Integer.parseInt(line1[0]);
int m = Integer.parseInt(line1[1]);
ArrayList<Student> list = new ArrayList<>();
String line;
while ((line = bf.readLine()) != null) {
Student s = new Student(Integer.parseInt(line.split(" ")[0]),
Integer.parseInt(line.split(" ")[1]));
list.add(s);
}
list.sort(new Comparator<Student>() {
@Override
public int compare(Student o1, Student o2) {
int i = o2.score - o1.score;//分数从高到低
//如分数相同再按id排序(升序)
//如果i非0,直接用分数差的正负值排序
i = i == 0 ? o1.id - o2.id : i;
return i;
}
});
int en_num = (int)Math.floor(m *1.5); //实际进面人数由分数线决定,同分可进,大于en_num数
int en_sco = list.get(en_num - 1).score;
int count = 0;//统计分数
for (int i = 0; i < n; i++) {
if (list.get(i).score < en_sco) {
break;
}
count++;
}
// System.out.println(m);
System.out.println(en_sco + " " + count);
for (int i = 0; i < count; i++) {
System.out.println(list.get(i));
}
}
}
class Student {
int id;
int score;
public Student(int id, int score) {
this.id = id;
this.score = score;
}
@Override
public String toString() {
return id + " " + score;
}
} import java.util.*;
import java.util.stream.Collectors;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int m = in.nextInt();
int t = (int) Math.floor(1.5 * m);
List<Candidate> candidates = new ArrayList<>();
while (n-- > 0) {
int k = in.nextInt();
int s = in.nextInt();
Candidate candidate = new Candidate(k, s);
candidates.add(candidate);
}
List<Candidate> collect = candidates.stream().sorted(Comparator.comparing(Candidate::getScore).reversed().thenComparing(Candidate::getId))
.collect(Collectors.toList());
int score = collect.get(t - 1).getScore();
List<Candidate> collect1 = collect.stream().filter(c -> c.getScore() >= score).collect(Collectors.toList());
System.out.println(score + " " + collect1.size());
collect1.forEach(c -> System.out.println(c.getId() + " " + c.getScore()));
}
}
class Candidate {
int id;
int score;
public Candidate(int id, int score) {
this.id = id;
this.score = score;
}
public int getId() {
return id;
}
public int getScore() {
return score;
}
} import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int m = scanner.nextInt();
int t = (int) (m * 1.5);
List<Candidate> candidates = new ArrayList<>();
for (int i = 0; i < n; i++) {
int k = scanner.nextInt();
int s = scanner.nextInt();
candidates.add(new Candidate(k, s));
}
// 排序:成绩从高到低,成绩相同报名号从小到大
// Override Comparator比较器
candidates.sort((o1, o2)-> {
if (o1.score != o2.score) return o2.score - o1.score;
else return o1.id - o2.id;
});
int line = candidates.get(t - 1).score;
int cnt = 0;
List<Candidate> interviewCandidates = new ArrayList<>();
for (Candidate candidate : candidates) {
if (candidate.score >= line) {
interviewCandidates.add(candidate);
cnt++;
}
}
System.out.println(line + " " + cnt);
for (Candidate candidate : interviewCandidates) {
System.out.println(candidate.id + " " + candidate.score);
}
scanner.close();
}
}
class Candidate {
int id;
int score;
public Candidate(int id, int score) {
this.id = id;
this.score = score;
}
}