Submission #1951079


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n,h; cin >> n >> h;
  vi a(n),b(n);
  int maxai=0,maxbi,i;
  rep(j,n){
    cin >> a[j] >> b[j];
    if(a[j] > maxai){
      maxai = a[j];
      i = j;
      maxbi = b[j];
    }
  }
  sort(all(b));
  int count = 0;
  int j = n-1;
  while(1){
    //cout << h << endl;
    if(h <= 0){
      cout << count << endl;
      break;
    }
    if(b[j] > maxai){//投げる
      h -= b[j];
      j--;
      count++;
    }else{//投げるより切る
      h -= maxai;
      count++;
    }
  }
}

Submission Info

Submission Time
Task D - Katana Thrower
User kimitsu_emt
Language C++14 (GCC 5.4.1)
Score 400
Code Size 957 Byte
Status AC
Exec Time 1009 ms
Memory 1024 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 840 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 87 ms 1024 KB
b07 AC 977 ms 256 KB
b08 AC 88 ms 1024 KB
b09 AC 977 ms 256 KB
b10 AC 489 ms 256 KB
b11 AC 489 ms 256 KB
b12 AC 327 ms 256 KB
b13 AC 1009 ms 1024 KB
b14 AC 33 ms 1024 KB
b15 AC 33 ms 1024 KB
b16 AC 521 ms 1024 KB
b17 AC 55 ms 1024 KB
b18 AC 48 ms 1024 KB
b19 AC 53 ms 1024 KB
b20 AC 45 ms 1024 KB
b21 AC 51 ms 1024 KB
b22 AC 54 ms 1024 KB
b23 AC 201 ms 256 KB
b24 AC 2 ms 256 KB