Submission #1950400


Source Code Expand

import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto nh = readln.chomp.split.to!(int[]);
  auto n = nh[0];
  auto h = nh[1];
  auto b = new int[](n);
  int amax;
  foreach (i; 0..n) {
    auto ab = readln.chomp.split.to!(int[]);
    b[i] = ab[1];
    amax = max(ab[0], amax);
  }
  int bsum;
  int cnt;
  b = b.sort!("b < a").array;

  foreach (i; 0..n) {
    if (b[i] > amax) {
      bsum += b[i];
      cnt++;
      if (bsum >= h) {
        break;
      }
    }
  }
  h -= bsum;
  if (h < 0) {
    h = 0;
  }
  cnt += h / amax;
  if (h % amax) {
    cnt++;
  }
  cnt.writeln;
}

Submission Info

Submission Time
Task D - Katana Thrower
User Fuh
Language D (DMD64 v2.070.1)
Score 400
Code Size 815 Byte
Status AC
Exec Time 128 ms
Memory 3964 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 1 ms 256 KB
a02 AC 1 ms 256 KB
a03 AC 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 128 ms 3580 KB
b07 AC 1 ms 256 KB
b08 AC 127 ms 2044 KB
b09 AC 1 ms 256 KB
b10 AC 1 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 95 ms 3580 KB
b14 AC 95 ms 2044 KB
b15 AC 95 ms 2044 KB
b16 AC 95 ms 2044 KB
b17 AC 115 ms 2044 KB
b18 AC 107 ms 3324 KB
b19 AC 102 ms 2044 KB
b20 AC 106 ms 3964 KB
b21 AC 112 ms 3324 KB
b22 AC 109 ms 3452 KB
b23 AC 1 ms 256 KB
b24 AC 4 ms 636 KB