Submission #1949073


Source Code Expand

import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int h = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int maxa = 0;
        for(int i=0; i<n; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            if(a[i] > maxa){
                maxa = a[i];
            }
        }
        sc.close();
        
        int ans = 0;
        Arrays.sort(b);

        for(int i=0; i<n; i++){
            if(b[n-i-1] > maxa && h > 0){
                h -= b[n-i-1];
                ans++;
            }else{
                break;
            }
        }

        if(h > 0){
            ans += h / maxa;
            if(h%maxa != 0){
                ans++;
            }
        }
        
        System.out.print(ans);
	}
}

Submission Info

Submission Time
Task D - Katana Thrower
User yukidaruma6
Language Java8 (OpenJDK 1.8.0)
Score 400
Code Size 959 Byte
Status AC
Exec Time 607 ms
Memory 66764 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 94 ms 20688 KB
a02 AC 94 ms 21716 KB
a03 AC 95 ms 18644 KB
a04 AC 95 ms 18644 KB
b05 AC 94 ms 21716 KB
b06 AC 607 ms 63940 KB
b07 AC 95 ms 19412 KB
b08 AC 605 ms 64756 KB
b09 AC 96 ms 20692 KB
b10 AC 101 ms 21460 KB
b11 AC 95 ms 20564 KB
b12 AC 96 ms 21076 KB
b13 AC 475 ms 61956 KB
b14 AC 484 ms 58800 KB
b15 AC 480 ms 63976 KB
b16 AC 538 ms 63208 KB
b17 AC 550 ms 63612 KB
b18 AC 533 ms 64412 KB
b19 AC 520 ms 62808 KB
b20 AC 498 ms 61988 KB
b21 AC 550 ms 64696 KB
b22 AC 558 ms 66764 KB
b23 AC 101 ms 20820 KB
b24 AC 164 ms 30760 KB