[SWEA] 1983 조교의 성적 매기기

Time Lapse :NONE

1983.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package com.ssafy.algo;


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int T, tc = 1, N;
T= sc.nextInt();
while(T--!=0) {
N = sc.nextInt();
final int target = sc.nextInt();
List<Score> scores = new ArrayList<>();
for(int i = 1; i <= N; ++i)
scores.add(new Score(sc.nextInt()*35 + sc.nextInt()*45 + sc.nextInt()*20, i));
System.out.print("#" + tc++ + " ");
switch ((int)((double) scores.stream()
.sorted((a,b) -> a.compareTo(b))
.collect(Collectors.toList())
.indexOf(scores.stream()
.filter(score -> score.num == target)
.collect(Collectors.toList())
.get(0)) / N * 10)){
case 0: System.out.println("A+"); break;
case 1: System.out.println("A0"); break;
case 2: System.out.println("A-"); break;
case 3: System.out.println("B+"); break;
case 4: System.out.println("B0"); break;
case 5: System.out.println("B-"); break;
case 6: System.out.println("C+"); break;
case 7: System.out.println("C0"); break;
case 8: System.out.println("C-"); break;
case 9: System.out.println("D0"); break;
default: break;
}
}

}
private static class Score implements Comparable<Score>{
int score;
int num;
public Score(int score, int num) {
this.score = score;
this.num = num;
}
@Override
public int compareTo(Score score) {
return -Integer.compare(this.score, score.score);
}
}
}
Author: Song Hayoung
Link: https://songhayoung.github.io/2020/08/04/PS/SWEA/1983/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.