Submission #1948064


Source Code Expand

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, h;
vector<int> a, b;


bool f(int m){
    int sum = 0;
    rep(i, 0, n){
        if(b[i] < a[0]) continue;
        sum += b[i];
        m--;
        if(m == 0) break;
    }
    sum += m * a[0];
    return sum >= h;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> h;
    a.resize(n); b.resize(n);
    rep(i, 0, n){
        cin >> a[i] >> b[i];
    }
    sort(all(a));
    reverse(all(a));
    sort(all(b));
    reverse(all(b));
    int l = 0, r = 1e9 + 10;
    rep(i, 0, 100){
        int mid = (l + r) / 2;
        if(f(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
}

Submission Info

Submission Time
Task D - Katana Thrower
User treeone
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1053 Byte
Status AC
Exec Time 36 ms
Memory 1920 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 33 ms 1792 KB
b07 AC 1 ms 256 KB
b08 AC 33 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 25 ms 1792 KB
b14 AC 21 ms 1920 KB
b15 AC 24 ms 1792 KB
b16 AC 25 ms 1792 KB
b17 AC 35 ms 1792 KB
b18 AC 33 ms 1792 KB
b19 AC 31 ms 1792 KB
b20 AC 28 ms 1792 KB
b21 AC 34 ms 1792 KB
b22 AC 36 ms 1792 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 256 KB