Submission #2236878
Source Code Expand
/* AC祈願アンコウ
/ ̄\
○ / ̄ ̄ ̄\ヘ
/・ ・ \>
/ ̄ ̄ ̄\ V|
| ――― | ||
\___/ ∧|
\ /
 ̄ ̄ ̄ ̄
*/
#include<bits/stdc++.h>
using namespace std;
#define int ll
typedef long long ll;
static const int MOD = 1000000007;
static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
#define YesNo(x) puts((x)?"Yes":"No")
void fastscan(int &number){
bool negative = false;
register int c;
while(!isdigit((c=getchar()))&&(c!='-')){}
ungetc(c,stdin);
number = 0;
c = getchar();
if(c=='-'){
negative = true;
c = getchar();
}
for(;(c>47 && c<58);c=getchar()) number = number *10 + c - 48;
if(negative) number *= -1;
}
signed main(){
int n,h;
cin >> n >> h;
pair<int,int> v[114514];
int Marx=-INF,Engels;
REP(i,n){
int tm,p;
fastscan(tm);
fastscan(p);
if(Marx<tm){
Marx = tm;
Engels = p;
}
v[i] = MP(p,tm);
}
int sum = 0,num = 0;
sort(v,v+n);
RREP(i,n){
if(v[i].FI<Marx) break;
/*if(v[i].fi==Engels){
Engelse = -1;
continue;
} else {*/
h -= v[i].FI;
num++;
if(h<=0){
printf("%lld\n",num);
return 0;
}
//}
}
printf("%lld\n",num+(h+Marx-1)/Marx);
return 0;
}
Submission Info
Submission Time |
|
Task |
D - Katana Thrower |
User |
r67pr |
Language |
C++14 (GCC 5.4.1) |
Score |
400 |
Code Size |
2626 Byte |
Status |
AC |
Exec Time |
24 ms |
Memory |
2048 KB |
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
400 / 400 |
Status |
|
|
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 |
2 ms |
2048 KB |
a02 |
AC |
2 ms |
2048 KB |
a03 |
AC |
2 ms |
2048 KB |
a04 |
AC |
2 ms |
2048 KB |
b05 |
AC |
2 ms |
2048 KB |
b06 |
AC |
24 ms |
2048 KB |
b07 |
AC |
2 ms |
2048 KB |
b08 |
AC |
24 ms |
2048 KB |
b09 |
AC |
2 ms |
2048 KB |
b10 |
AC |
2 ms |
2048 KB |
b11 |
AC |
2 ms |
2048 KB |
b12 |
AC |
2 ms |
2048 KB |
b13 |
AC |
11 ms |
2048 KB |
b14 |
AC |
11 ms |
2048 KB |
b15 |
AC |
11 ms |
2048 KB |
b16 |
AC |
11 ms |
2048 KB |
b17 |
AC |
21 ms |
2048 KB |
b18 |
AC |
20 ms |
2048 KB |
b19 |
AC |
16 ms |
2048 KB |
b20 |
AC |
18 ms |
2048 KB |
b21 |
AC |
20 ms |
2048 KB |
b22 |
AC |
21 ms |
2048 KB |
b23 |
AC |
2 ms |
2048 KB |
b24 |
AC |
2 ms |
2048 KB |