Submission #52116983


Source Code Expand

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        int[] a = new int[n];
        int[] c = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        System.out.println(solve(n, a, c));
    }

    static String solve(int n, int[] a, int[] c) {
        HashMap<Integer, Integer> cmin = new HashMap<>();
        for(int i=0; i<n; i++) {
            cmin.put(c[i], Math.min(a[i], cmin.getOrDefault(c[i], Integer.MAX_VALUE)));
        }
        int result = 0;
        for(Integer ai: cmin.values()) {
            result = Math.max(result, ai);
        }

        return String.valueOf(result).trim();
    }
}

Submission Info

Submission Time
Task C - Colorful Beans
User ToshiChan
Language Java (OpenJDK 17)
Score 250
Code Size 818 Byte
Status AC
Exec Time 719 ms
Memory 74716 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 250 / 250
Status
AC × 2
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 02_maximum_00.txt, 02_maximum_01.txt, 02_maximum_02.txt, 02_maximum_03.txt, 02_maximum_04.txt, 02_maximum_05.txt, 02_maximum_06.txt, 02_maximum_07.txt, 02_maximum_08.txt, 02_maximum_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 79 ms 37740 KiB
00_sample_01.txt AC 73 ms 38000 KiB
01_random_00.txt AC 383 ms 62676 KiB
01_random_01.txt AC 308 ms 58120 KiB
01_random_02.txt AC 634 ms 74716 KiB
01_random_03.txt AC 347 ms 60432 KiB
01_random_04.txt AC 631 ms 65824 KiB
01_random_05.txt AC 599 ms 64972 KiB
01_random_06.txt AC 600 ms 64464 KiB
01_random_07.txt AC 561 ms 65976 KiB
01_random_08.txt AC 543 ms 64208 KiB
01_random_09.txt AC 639 ms 67404 KiB
01_random_10.txt AC 266 ms 57868 KiB
01_random_11.txt AC 432 ms 63448 KiB
01_random_12.txt AC 602 ms 66236 KiB
01_random_13.txt AC 562 ms 64860 KiB
01_random_14.txt AC 312 ms 58016 KiB
01_random_15.txt AC 594 ms 65280 KiB
01_random_16.txt AC 401 ms 62024 KiB
01_random_17.txt AC 513 ms 64448 KiB
02_maximum_00.txt AC 669 ms 67320 KiB
02_maximum_01.txt AC 699 ms 68340 KiB
02_maximum_02.txt AC 604 ms 65480 KiB
02_maximum_03.txt AC 665 ms 67788 KiB
02_maximum_04.txt AC 676 ms 67856 KiB
02_maximum_05.txt AC 651 ms 69432 KiB
02_maximum_06.txt AC 645 ms 68648 KiB
02_maximum_07.txt AC 712 ms 68664 KiB
02_maximum_08.txt AC 701 ms 69756 KiB
02_maximum_09.txt AC 719 ms 69988 KiB