Submission #3426600


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;
#define pri(a) cout << (a) << endl


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N , H;
	cin >> N >> H;
	priority_queue<P> Q;
	FOR(i,0,N){
		ll a,b;
		cin >> a >> b;
		Q.push({a,1});
		Q.push({b,0});
	}
	ll ans = 0;
	while(H>0){
		ans++;
		P x = Q.top();
		if(x.second==0)Q.pop();
		if(x.second==0){
			H -= x.first;
		}else{
			ll k = H / x.first;
			ans += k-1;
			H -= k*x.first;
		}
	}
	cout << ans << endl;
}

Submission Info

Submission Time
Task D - Katana Thrower
User kenta2997
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1060 Byte
Status TLE
Exec Time 2103 ms
Memory 6384 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
TLE × 1
AC × 19
TLE × 5
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 TLE 2103 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 4976 KB
b07 AC 1 ms 256 KB
b08 TLE 2103 ms 4848 KB
b09 AC 1 ms 256 KB
b10 TLE 2103 ms 256 KB
b11 AC 1 ms 256 KB
b12 AC 1 ms 256 KB
b13 AC 24 ms 5360 KB
b14 AC 20 ms 6384 KB
b15 AC 16 ms 6256 KB
b16 AC 15 ms 4464 KB
b17 AC 21 ms 5488 KB
b18 TLE 2103 ms 5104 KB
b19 AC 30 ms 6128 KB
b20 AC 26 ms 5744 KB
b21 AC 32 ms 4464 KB
b22 AC 34 ms 4976 KB
b23 AC 1 ms 256 KB
b24 TLE 2103 ms 512 KB