-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathFORESTGA
More file actions
54 lines (41 loc) · 912 Bytes
/
FORESTGA
File metadata and controls
54 lines (41 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
using namespace std;
typedef long long ll;
typedef long double ld;
#include<bits/stdc++.h>
#include "limits.h"
typedef priority_queue<ll> pq;
#define pb push_back
#define mp make_pair
#define find_max *max_element
#define mod 1
ll N,W,L;
ll cal_wood(ll t,ll H[],ll R[]){
ll woods=0;
for(ll i=0;i<N;++i){
ll temp=H[i]+(R[i]*t);
if(temp>=L)woods+=temp;
if(woods>=W)return woods;
}
return woods;
}
int main() {
cin>>N>>W>>L;
ll H[N],R[N];
for(ll i=0;i<N;++i)cin>>H[i]>>R[i];
ll temp=cal_wood(0,H,R);
if(temp>=W)cout<<"0\n";
else{
ll i=1,j=1e+18;
ll month=-1;
while(i<=j){
ll mid=(i+j)/2;
ll temp=cal_wood(mid,H,R);
if(temp>=W){
month=mid;
j=mid-1;
}else i=mid+1;
}
cout<<month<<"\n";
}
}