#include #include using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000000000 #pragma target("avx2") #pragma optimize("O3") #pragma optimize("unroll-loops") long long dp[2505][2505],ndp[2505][2505]; bool f[2505][2505]; vector> get(vector x,vector c,vector v,int C,int W){ rep(i,C+1){ rep(j,W+1)dp[i][j] = -Inf; } dp[0][0] = 0; rep(i,x.size()){ //cout<W){ ndp[j][k] = max(ndp[j][k],dp[j][k]); continue; } deque> D; int jj = j,kk = k; while(true){ if(jj>C||kk>W)break; f[jj][kk] = true; while(D.size()>0&&jj - D.front().second > c[i])D.pop_front(); if(dp[jj][kk]!=-Inf){ while(D.size()>0 && D.back().first<=dp[jj][kk] - v[i] * jj)D.pop_back(); D.emplace_back(dp[jj][kk] - v[i] * jj, jj); } if(D.size()>0)ndp[jj][kk] = max(ndp[jj][kk],v[i]*jj + D.front().first); jj++; kk+=x[i]; } } } swap(dp,ndp); } vector> ret(C+1,vector(W+1)); rep(i,ret.size()){ rep(j,ret[i].size())ret[i][j] = dp[i][j]; } return ret; } int main() { int N; cin>>N; vector c(N+1); vector v(N+1); rep(i,N){ cin>>c[i+1]>>v[i+1]; c[i+1] = min(c[i+1],N/(i+1)); v[i+1] += 1000000000; } vector xx,cc; vector vv; for(int i=1;i<=min(N,50);i++){ xx.push_back(i); cc.push_back(c[i]); vv.push_back(v[i]); } //cout<<'a'< ans(N+1,-Inf); rep(i,dpx.size()){ rep(j,dpy.size()){ if(i+j>N)break; rep(k,N+1){ ans[i+j] = max(ans[i+j],dpx[i][k] + dpy[j][N-k]); } } } rep(i,N){ ans[i+1] -= 1000000000LL * (i+1); cout<