Submission #1951855


Source Code Expand

#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N, H;
    cin >> N >> H;

    using P = tuple<int, int>;

    priority_queue<P, vector<P>> q;
    vector<int> A(N);
    vector<int> B(N);
    REP(n, N) {
        cin >> A[n] >> B[n];
        q.push( mt(B[n], 1) );
        q.push( mt(A[n], 0) );
    }

    int ans = 0;
    while (H > 0) {
        auto p = q.top();
        auto damage = get<0>(p);
        if (get<1>(p) == 1) {
            q.pop();
            H -= damage;
            ans++;
        }
        else {
            ans += (H + (damage - 1)) / damage;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

Submission Info

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