Submission #4672334


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(){
    int N, H; cin >> N >> H;
    
    int maxA = 0;
    vector<pair<int, int>> tmpvec(N);
    for(int i=0; i<N; i++){
        int a, b; cin >> a >> b;
        maxA = max(maxA, a);
        tmpvec[i] = {b, a};
    }

    vector<int> bvec;
    for(int i=0; i<N; i++){
        if(tmpvec[i].first >= maxA){
            bvec.push_back(tmpvec[i].first);
        }
    }

    sort(bvec.begin(), bvec.end(), greater<int>());
    //for(int i=0; i<bvec.size(); i++) cout << bvec[i] << endl;
    int B_sum = 0;
    for(int i=0; i<bvec.size(); i++){
        B_sum += bvec[i];
        if(B_sum >= H){
            cout << i+1 << endl;
            //cout << 55 << endl;
            return 0;
        }
    }

    cout << (H - B_sum - 1) / maxA + 1 + bvec.size() << endl;
}

Submission Info

Submission Time
Task D - Katana Thrower
User ose20
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1078 Byte
Status AC
Exec Time 88 ms
Memory 1660 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 87 ms 1660 KB
b07 AC 1 ms 256 KB
b08 AC 88 ms 1660 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 34 ms 1660 KB
b14 AC 34 ms 1660 KB
b15 AC 34 ms 1660 KB
b16 AC 34 ms 1660 KB
b17 AC 49 ms 1024 KB
b18 AC 43 ms 1024 KB
b19 AC 41 ms 1660 KB
b20 AC 44 ms 1660 KB
b21 AC 52 ms 1660 KB
b22 AC 54 ms 1660 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 256 KB