Submission #1949267


Source Code Expand

Copy
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include <unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000+10

ll N,H;
ll A[VMAX],B[VMAX];
ll ans;


int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N>>H;
    REP(i,N){
        cin>>A[i]>>B[i];
    }
    std::sort(A,A+N);std::sort(B,B+N);
    REP(i,N){
        if(A[N-1]<B[N-1-i])H-=B[N-1-i];
        else break;
        ans++;
        if(H<=0){
            cout<<ans<<endl;
            return 0;
        }
    }
    DEB(ans)
    ans+=(H%A[N-1]==0?H/A[N-1]:H/A[N-1]+1);
    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User Nafmo2
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1419 Byte
Status
Exec Time 28 ms
Memory 1792 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03, a04
All 400 / 400 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 1 ms 256 KB
a02 1 ms 256 KB
a03 1 ms 256 KB
a04 1 ms 256 KB
b05 1 ms 256 KB
b06 25 ms 1792 KB
b07 1 ms 256 KB
b08 25 ms 1792 KB
b09 1 ms 256 KB
b10 1 ms 256 KB
b11 1 ms 256 KB
b12 1 ms 256 KB
b13 15 ms 1792 KB
b14 15 ms 1792 KB
b15 15 ms 1792 KB
b16 15 ms 1792 KB
b17 28 ms 1792 KB
b18 25 ms 1792 KB
b19 20 ms 1792 KB
b20 22 ms 1792 KB
b21 25 ms 1792 KB
b22 27 ms 1792 KB
b23 1 ms 256 KB
b24 2 ms 256 KB