using System; using System.Collections.Generic; using System.Collections; using System.Collections.Specialized; using System.Linq; using System.Text; using System.IO; using System.Reflection; using static System.Math; using System.Numerics; static class Program{ const int mod=(int)1e9+7; const double eps=1e-11; static void Main(){ Sc sc=new Sc(); var n=sc.I; const int m=100001,inf=int.MaxValue>>1; var dp=Enumerable.Repeat(inf,m).ToArray(); int p=dp[0]=0; for(int i = 0;i=0;j--) { if(j>=e[0]){dp[j]=Min(dp[j-e[0]],dp[j]+e[1]);} else{dp[j]+=e[1];} } p+=e[0]; } int ans=m; for(int i = 0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i(int n,Func f){var a=new T[n];for(int i=0;i