Notice
Recent Posts
Recent Comments
Link
«   2025/02   »
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
Tags
more
Archives
Today
Total
관리 메뉴

forDevLife

[백준] 17224 - APC는 왜 서브태스크 대회가 되었을까? 본문

알고리즘

[백준] 17224 - APC는 왜 서브태스크 대회가 되었을까?

JH_Lucid 2021. 6. 13. 17:52

 

- 어려운 문제 오름차순으로 정렬(같을 경우 쉬운 문제 기준으로)

- 어려운 문제 풀 수 있으면 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);

    }
}
Comments