/** * Problem: Talent Show G * File: Talent Show G.cpp * Create Date: 2025/10/8/14:30 * Last Change Date: 2025/10/8 * Editor: code-server * Powered by 1000ttank */ #include<bits/stdc++.h> usingnamespace std; #define int long long // #define int __int128 #define endl '\n'
constdouble ex=1e-8; constint maxn=260; constint maxt=1e6+10; structNode { int w,t; }; int n,w; vector<Node> a; boolcheck(int k){ vector<int> dp(w+1,-1e15); dp[0]=0; for (int i=1;i<=n;i++) { for (int j=w;j>=0;j--) { if (dp[j]!=-1e15) { int shld=min(j+a[i].w,w); dp[shld]=max(dp[shld],dp[j]+a[i].t-a[i].w*k); } } } return dp[w]>=0; } voidsolve(){ cin >> n >> w; a.assign(n+1,{0,0}); for (int i=1;i<=n;i++) { cin >> a[i].w >> a[i].t; a[i].t*=1000; } /* \sigma_{Z[i]} ------------- >= mid \sigma_{W[i]} \sigma_{Z[i]}-\sigma_{W[i]}*mid >= 0 \sigma_{Z[i]-W[i]*mid} >= 0 */
int l=0,r=1000000; while (l<=r) { int mid=(l+r)/2; if (check(mid)) l=mid+1; else r=mid-1; } cout << l-1 << endl; } voidinit(){ } signedmain(){ // #Define CONTEST_MODEL #ifdef CONTEST_MODEL #ifndef LOCAL freopen("Luogu-P4377.in","r",stdin); freopen("Luogu-P4377.out","w",stdout); #endif #endif
ios::sync_with_stdio(false); cin.tie(nullptr); init(); int T=1; // cin >> T; while (T--) { solve(); } return0; }