#include #define W 100000 typedef long long ll; using namespace std; int N, V; vector value(101, 0); vector weight(101, 0); vector dp(100001, 0); //dp[i]に「重さi以内で得られる価値の最大値」 int main(void){ cin >> N; for(int i = 0; i < N; ++i) cin >> value[i] >> weight[i]; cin >> V; for(int j = 0; j < N; ++j){ for(int i = W; i >= weight[j]; --i) dp[i] = max(dp[i], dp[i - weight[j]] + value[j]); } int i, num; for(i = 1; i <= W; ++i){ if(dp[i] >= V){ cout << (num = i) << endl; break; } } for(; i <= W; ++i){ if(dp[i] > dp[num]){ cout << i - 1 << endl; return 0; } } cout << "inf" << endl; return 0; }