Submission #1949388


Source Code Expand

#include <algorithm>
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::sort;
using std::abs;

using std::fixed;
using std::setprecision;
using std::setw;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 314;

int main() {
    ll n, h;
    cin >> n >> h;

    vector<ll> a(n);
    vector<ll> b(n);
    for(ll i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }

    sort(a.begin(), a.end(), std::greater<ll>());
    sort(b.begin(), b.end(), std::greater<ll>());

    ll sum_b = 0;
    ll ans = (h + a[0] - 1) / a[0];
    for (ll i = 0; i < n; i++) {
        sum_b += b[i];

        ll j = h - sum_b;
        if(j <= 0){
            ans = min(ans, i + 1);
        }else{
            ans = min(ans, i + 1 + (j + a[0] - 1) / a[0]);
        }
    }

    cout << ans << endl;

    return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User somq14
Language C++14 (Clang 3.8.0)
Score 400
Code Size 1305 Byte
Status AC
Exec Time 217 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 217 ms 1792 KB
b07 AC 1 ms 256 KB
b08 AC 217 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 94 ms 1792 KB
b14 AC 93 ms 1792 KB
b15 AC 92 ms 1792 KB
b16 AC 93 ms 1792 KB
b17 AC 150 ms 1792 KB
b18 AC 132 ms 1792 KB
b19 AC 113 ms 1792 KB
b20 AC 122 ms 1792 KB
b21 AC 136 ms 1792 KB
b22 AC 150 ms 1792 KB
b23 AC 1 ms 256 KB
b24 AC 5 ms 256 KB