Submission #1947327


Source Code Expand

#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<bitset>
#include<random>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,h;
	cin>>n>>h;
	vector<ll> a(n);
	vector<ll> b(n);
	REP(i,n) cin>>a[i]>>b[i];
	sort(ALL(a));
	sort(ALL(b));
	ll buf=a[n-1];
	ll ans=INF*INF;
	ll sum=0;
	REP(i,n) {
		sum+=b[n-1-i];
		ll tmp=i+1;
		if(sum<h) {
			tmp+=(h-sum-1)/buf+1;
		}
		ans=min(ans,tmp);
	}
	cout<<ans<<endl;
}

Submission Info

Submission Time
Task D - Katana Thrower
User gazelle
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1038 Byte
Status AC
Exec Time 29 ms
Memory 1792 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 1792 KB
b07 AC 1 ms 256 KB
b08 AC 25 ms 1792 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 17 ms 1792 KB
b14 AC 16 ms 1792 KB
b15 AC 15 ms 1792 KB
b16 AC 16 ms 1792 KB
b17 AC 29 ms 1792 KB
b18 AC 26 ms 1792 KB
b19 AC 21 ms 1792 KB
b20 AC 22 ms 1792 KB
b21 AC 26 ms 1792 KB
b22 AC 27 ms 1792 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 256 KB