Submission #1953785


Source Code Expand

#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int N;
long long H;
const int MAX = 110000;

typedef pair<long long,long long> pll;
pll inp[MAX];

long long sum[MAX];

int main() {
    while (cin >> N >> H) {
        for (int i = 0; i < N; ++i) {
            cin >> inp[i].second >> inp[i].first;
        }
        sort(inp, inp+N, greater<pll>());
        
        long long maxa = 0;
        sum[0] = 0;
        for (int i = 0; i < N; ++i) {
            sum[i+1] = sum[i] + inp[i].first;
            chmax(maxa, inp[i].second);
        }
        
        long long res = H;
        for (long long i = 0; i <= N; ++i) {
            long long rem = H - sum[i];
            if (rem < 0) {
                chmin(res, i);
                continue;
            }
            long long add = (rem + maxa - 1) / maxa;
            chmin(res, add + i);
        }
        cout << res << endl;
    }
}




Submission Info

Submission Time
Task D - Katana Thrower
User drken
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2302 Byte
Status AC
Exec Time 89 ms
Memory 2560 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 89 ms 2560 KB
b07 AC 1 ms 256 KB
b08 AC 89 ms 2560 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 36 ms 2560 KB
b14 AC 35 ms 2560 KB
b15 AC 35 ms 2560 KB
b16 AC 36 ms 2560 KB
b17 AC 58 ms 2560 KB
b18 AC 53 ms 2560 KB
b19 AC 45 ms 2560 KB
b20 AC 50 ms 2560 KB
b21 AC 54 ms 2560 KB
b22 AC 59 ms 2560 KB
b23 AC 1 ms 256 KB
b24 AC 3 ms 256 KB