Submission #1948570


Source Code Expand

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  LL N, H;
  cin >> N >> H;
  vector<LL> xs(N);
  LL mx = 0;
  REP(i,N){
	LL a;
	cin >> a >> xs[i];
	maxi(mx, a);
  }
  RSORT(xs);

  LL ans = H;
  REP(i,N){
	H -= xs[i];
	mini(ans, i+1 + (H>0? (H+mx-1)/mx: 0ll));
	if(H <= 0) break;
  }
  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User okaduki
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1649 Byte
Status AC
Exec Time 25 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 1 ms 256 KB
a04 AC 1 ms 256 KB
b05 AC 1 ms 256 KB
b06 AC 25 ms 1024 KB
b07 AC 1 ms 256 KB
b08 AC 24 ms 1024 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 15 ms 1024 KB
b14 AC 14 ms 1024 KB
b15 AC 14 ms 1024 KB
b16 AC 15 ms 1024 KB
b17 AC 23 ms 1024 KB
b18 AC 21 ms 1024 KB
b19 AC 17 ms 1024 KB
b20 AC 19 ms 1024 KB
b21 AC 22 ms 1024 KB
b22 AC 21 ms 1024 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 256 KB