| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 200522 | arnold518 | 스트랩 (JOI14_straps) | C++14 | 173 ms | 63780 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;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int MAXN = 2000;
const ll INF = 1e18;
int N, A[MAXN+10], B[MAXN+10];
ll dp[MAXN+10][MAXN*2+10];
ll solve(int pos, int val)
{
	if(pos==N+1)
	{
		if(val>=-1) return 0;
		else return -INF; 
	}
	ll &ret=dp[pos][val+MAXN];
	if(ret!=-1) return ret;
	ret=-INF;
	ret=max(ret, solve(pos+1, val));
	ret=max(ret, solve(pos+1, min(N, val+A[pos]))+B[pos]);
	return ret;
}
int main()
{
	int i, j;
	scanf("%d", &N);
	for(i=1; i<=N; i++) scanf("%d%d", &A[i], &B[i]), A[i]--;
	memset(dp, -1, sizeof(dp));
	printf("%lld\n", solve(1, 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... | ||||
