Submission #1948613


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  int H = nextInt();
  vector<int> bs;
  int max_a = 0;
  REP(i, N) {
    int a = nextInt();
    int b = nextInt();
    bs.push_back(b);
    max_a = max(max_a, a);
  }
  sort(ALL(bs));
  reverse(ALL(bs));
  int p = 0;
  int ans = 0;
  while (H > 0) {
    if (p < N && bs[p] > max_a) {
      H -= bs[p++];
      ans++;
    } else {
      ans += (H + max_a - 1) / max_a;
      H = 0;
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}

Submission Info

Submission Time
Task D - Katana Thrower
User hs484
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1106 Byte
Status AC
Exec Time 26 ms
Memory 892 KB

Compile Error

./Main.cpp: In function ‘int nextInt()’:
./Main.cpp:14:39: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 int nextInt() { int x; scanf("%d", &x); return x;}
                                       ^

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 892 KB
b07 AC 1 ms 256 KB
b08 AC 26 ms 892 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 17 ms 892 KB
b14 AC 18 ms 892 KB
b15 AC 18 ms 892 KB
b16 AC 18 ms 892 KB
b17 AC 25 ms 892 KB
b18 AC 23 ms 892 KB
b19 AC 20 ms 892 KB
b20 AC 21 ms 892 KB
b21 AC 24 ms 892 KB
b22 AC 23 ms 892 KB
b23 AC 1 ms 256 KB
b24 AC 2 ms 256 KB