| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 46856 | ffresh | 스트랩 (JOI14_straps) | C++17 | 13 ms | 760 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 2005,inf = -2e9-150;
int dp[N];
pair<int,int> inp[N];
int main(){
    //freopen("input.txt","r",stdin);
    int n;
    scanf("%d",&n);
    int a,b,ret=0;
    
    for(int i=0;i<N;++i)dp[i]= inf;
    dp[1]= 0;
    
    for(int i=0;i<n;++i){
        scanf("%d%d",&inp[i].first,&inp[i].second);
    }
    sort(inp,inp+n,greater<pair<int,int> >());
    for(int i=0;i<n;++i){
        int x = inp[i].first-1, y = inp[i].second;
        if(x<0){
            for(int j=1;j<=n;++j)
                if(dp[j]!=inf)dp[j-1]= max(dp[j-1],dp[j]+y);
        }
        else{
            for(int j=n;j>=1;--j){
                int nj = min(n,j+x);
                if(dp[j]!=inf)
                    dp[nj]= max(dp[nj], dp[j] + y);
            }
        }
    }
    for(int i=0;i<=n;++i)ret= max(ret,dp[i]);
    printf("%d\n",ret);
    return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
