//TLE Θ(N^3) #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using namespace atcoder; //using mint = modint998244353; #define rep(i,n) for (int i=0;i-1;i--) #define append push_back #define all(x) (x).begin(), (x).end() template using vec = vector; template using vvec = vec>; template using vvvec = vec>; using ll = long long; using pii = pair; using pll = pair; template bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template bool chmax(T &a, T b){ if (a T sum(vec x){ T res=0; for (auto e:x){ res += e; } return res; } template void printv(vec x){ for (auto e:x){ cout<>= 1; } return res; } ll dp[2501][2501]; pair deq[2501]; ll INF = 1e17; int l = 0, r = 0; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int N; cin>>N; rep(i,N+1){ rep(j,N+1){ dp[i][j] = -INF; } } dp[0][0] = 0; vec> item; rep(i,N){ int c; ll v; cin>>c>>v; item.append({c,v}); } rep(i,2501){ deq[i] = {-1,-INF}; } rep(i,N){ auto [c,v] = item[i]; for (int w_start=0;w_start