Advertisement
nguyentien281006

OLYMPIA

Nov 27th, 2022
813
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.21 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define tasks "OLYMPIA"
  5. #define sync_in_out ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  6. #define int long long
  7. #define pii pair<long long, long long>
  8. #define X first
  9. #define Y second
  10.  
  11. struct inpt{
  12.     int a, b, t;
  13. };
  14.  
  15. vector<inpt> st;
  16. int n, c, k, cnt = 0;
  17.  
  18.  
  19. bool cmp(inpt u, inpt v){
  20.     return u.t < v.t;
  21. }
  22.  
  23. signed main(){
  24.     sync_in_out
  25.     if(fopen(tasks".inp", "r")){
  26.         freopen(tasks".inp", "r", stdin);
  27.         freopen(tasks".out", "w", stdout);
  28.     }
  29.     cin >> n >> c >> k;
  30.     st.resize(n+5);
  31.     for(int i = 1; i <= n; i++){
  32.         int x, y; cin >> x >> y;
  33.         if(y != 0){
  34.             st[i].a = x; st[i].b = y; st[i].t = ceil(double(k-x)/(double)y);
  35.         }
  36.         if(y == 0) {
  37.             st[i].a = x; st[i].b = y; st[i].t = 0;
  38.         }
  39.     }
  40.     sort(st.begin() + 1, st.begin() + n + 1, cmp);
  41.     for(int i = 1; i <= n; i++) {
  42.         if(st[i].a >= k){
  43.             cnt++;
  44.             continue;
  45.         }
  46.         if(st[i].b == 0) continue;
  47.         if(c >= st[i].t && c > 0){
  48.             c -= st[i].t;
  49.             cnt++;
  50.             continue;
  51.         }
  52.        
  53.     }
  54.     cout << cnt;
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement