Submission #3912410


Source Code Expand

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using System.Threading.Tasks;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int N = cin.nextInt();
        int H = cin.nextInt();
        int[] a = new int[N];
        int[] b = new int[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = cin.nextInt();
            b[i] = cin.nextInt();
        }

        Array.Sort(b);
        Array.Reverse(b);

        int MaxA = a.Max();

        int ans = 0;

        for (int i = 0; i < N; i++)
        {
            if(MaxA < b[i] && H > 0)
            {
                H -= b[i];
                ans++;
            }
        }

        ans += Math.Max(0, (H + MaxA - 1) / MaxA);

        Console.WriteLine(ans);
    }
    
}




class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Submission Info

Submission Time
Task D - Katana Thrower
User chokudai
Language C# (Mono 4.6.2.0)
Score 400
Code Size 2524 Byte
Status AC
Exec Time 145 ms
Memory 15952 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 23 ms 13268 KB
a02 AC 23 ms 11220 KB
a03 AC 23 ms 11220 KB
a04 AC 23 ms 11220 KB
b05 AC 23 ms 9172 KB
b06 AC 145 ms 15936 KB
b07 AC 24 ms 13268 KB
b08 AC 142 ms 15936 KB
b09 AC 23 ms 11220 KB
b10 AC 23 ms 11220 KB
b11 AC 23 ms 11220 KB
b12 AC 23 ms 11348 KB
b13 AC 102 ms 15952 KB
b14 AC 104 ms 13904 KB
b15 AC 104 ms 13904 KB
b16 AC 105 ms 13904 KB
b17 AC 127 ms 15948 KB
b18 AC 120 ms 13900 KB
b19 AC 113 ms 15952 KB
b20 AC 117 ms 13904 KB
b21 AC 123 ms 13900 KB
b22 AC 123 ms 13900 KB
b23 AC 23 ms 9172 KB
b24 AC 25 ms 11316 KB