fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define FOR(i,a,b) for (int i=(a),_b=(b);i<=_b;i=i+1)
  4. #define FORD(i,b,a) for (int i=(b),_a=(a);i>=_a;i=i-1)
  5. #define REP(i,n) for (int i=0,_n=(n);i<_n;i=i+1)
  6. #define FORE(i,v) for (__typeof((v).begin()) i=(v).begin();i!=(v).end();i++)
  7. #define ALL(v) (v).begin(),(v).end()
  8. #define pb push_back
  9. #define mp make_pair
  10. #define fi first
  11. #define se second
  12. #define SZ(x) ((int)(x).size())
  13. #define double db
  14. typedef long long ll;
  15. typedef pair<ll,ll> PII;
  16. const ll mod=1000000007;
  17. ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
  18. const int MAXN = 1E6+3;
  19. const int oo = 1e9+3;
  20.  
  21. int n;
  22. ll ans, b;
  23. PII a[MAXN];
  24.  
  25. bool cmp(PII a, PII b) {
  26.   return (a.fi < b.fi);
  27. }
  28.  
  29. int main() {
  30.   cin >> n >> b;
  31.   FOR(i,1,n) cin >> a[i].fi >> a[i].se;
  32.   sort(a+1,a+n+1,cmp);
  33.   FOR(i,1,n) {
  34.   if (b < a[i].fi) break;
  35.   ll tmp = b / a[i].fi;
  36.   b -= min(tmp,a[i].se) * a[i].fi;
  37.   ans += min(tmp,a[i].se);
  38.   }
  39. cout << ans;
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.pas:1: warning: missing program header
prog.pas:1: error: syntax error before `<'
stdout
Standard output is empty