forDevLife
[백준] 17224 - APC는 왜 서브태스크 대회가 되었을까? 본문
- 어려운 문제 오름차순으로 정렬(같을 경우 쉬운 문제 기준으로)
- 어려운 문제 풀 수 있으면 140점, 쉬운 것만 가능하면 100점으로 계산
- 문제 풀이 후에, 풀 수 있는 문제 수 K--
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
class Quiz {
int easy;
int dif;
public Quiz(int easy, int dif) {
this.easy = easy;
this.dif = dif;
}
}
public class Main {
public static void main(String args[]) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
int N = Integer.parseInt(st.nextToken());
int L = Integer.parseInt(st.nextToken()); // 역량
int K = Integer.parseInt(st.nextToken()); // 최대 문제 풀이
ArrayList<Quiz> arrayList = new ArrayList<>();
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine(), " ");
arrayList.add(new Quiz(Integer.parseInt(st.nextToken()), Integer.parseInt(st.nextToken())));
}
Collections.sort(arrayList, new Comparator<Quiz>() {
@Override
public int compare(Quiz o1, Quiz o2) {
if (o1.dif == o2.dif) {
return o1.easy - o2.easy;
} else
return o1.dif - o2.dif;
}
});
int result = 0;
for (int i = 0; i < N; i++) {
Quiz temp = arrayList.get(i);
if (K > 0) {
if (temp.dif <= L) {
result += 140;
K--;
} else if (temp.easy <= L) {
result += 100;
K--;
}
} else
break;
}
System.out.println(result);
}
}
'알고리즘' 카테고리의 다른 글
[백준] 1417 - 국회의원 선거 (0) | 2021.06.14 |
---|---|
[백준] 1343 - 폴리오미노 (0) | 2021.06.14 |
[백준] 2839 - 설탕 배달 (0) | 2021.06.11 |
[백준] 2828 - 사과 담기 게임 (0) | 2021.06.09 |
[백준] 14659 - 한조서열정리하고옴ㅋㅋ (0) | 2021.06.09 |
Comments