#include #include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf32 1000000001 #define Inf64 1000000000000000001 using P = pair; P op(P a,P b){ if(a.first>b.first)return a; if(a.first>N>>W; vector

dp(20001,e()); int c = 10000; dp[c] = make_pair(0,1); rep(i,N){ int v,w; cin>>v>>w; vector

ndp(200001,e()); rep(j,200001){ P val = dp[j]; if(val.first==-Inf32)continue; ndp[j] = op(ndp[j],val); int nj = j + w; if(nj<0 || nj>=ndp.size())continue; //P val = dp[j]; val.first += v; ndp[nj] = op(ndp[nj],val); } swap(dp,ndp); } W += c; P ans = e(); rep(i,W+1){ ans = op(ans,dp[i]); } if(ans.first==-Inf32){ ans.first = 0,ans.second = 1; } cout<