#include using namespace std; #define FOR(i, n) for(int i = 0; i < (n); i++) #define MEM(a, x) memset(a, x, sizeof(a)) #define ALL(a) a.begin(), a.end() #define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) typedef long long ll; typedef pair P; int n, V, dp[100005]; int main(int argc, char const *argv[]) { ios_base::sync_with_stdio(false); cin >> n; vector

vw(n); FOR(i, n) cin >> vw[i].first >> vw[i].second; cin >> V; FOR(i, n) { int _dp[100005]; FOR(j, 100005) { if (j-vw[i].second >= 0) _dp[j] = max(dp[j], dp[j-vw[i].second] + vw[i].first); else _dp[j] = dp[j]; } FOR(j, 100005) dp[j] = _dp[j]; } cout << max((int)(upper_bound(dp, dp+100005, V-1)-dp), 1) << endl; int ma = (int)(upper_bound(dp, dp+100005, V)-dp)-1; if (ma == 100004) cout << "inf" << endl; else cout << ma << endl; return 0; }