Submission #25578

# Submission time Handle Problem Language Result Execution time Memory
25578 2017-06-23T05:57:56 Z khsoo01 스트랩 (JOI14_straps) C++11
100 / 100
29 ms 33456 KB
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
const ll inf = 1e18;

ll n, dt[2005][2005];
pair<ll,ll> a[2005];

int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++) {
		scanf("%lld%lld",&a[i].X,&a[i].Y);
		a[i].X *= -1;
	}
	sort(a+1, a+1+n);
	for(ll i=1;i<=n;i++) a[i].X *= -1;
	for(ll i=0;i<=n;i++) {
		for(ll j=0;j<=n;j++) dt[i][j] = -inf;
	}
	dt[0][1] = 0;
	for(ll i=1;i<=n;i++) {
		dt[i][0] = dt[i-1][0];
		for(ll j=1;j<=n;j++) {
			dt[i][j] = max(dt[i][j], dt[i-1][j]);
			if(j + a[i].X - 1 >= 0) {
				ll X = min(n, j+a[i].X-1);
				dt[i][X] = max(dt[i][X], dt[i-1][j] + a[i].Y);
			}
		}
	}
	ll ans = 0;
	for(ll i=0;i<=n;i++) ans = max(ans, dt[n][i]);
	printf("%lld\n",ans);
}

Compilation message

straps.cpp: In function 'int main()':
straps.cpp:13:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld",&n);
                  ^
straps.cpp:15:36: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%lld",&a[i].X,&a[i].Y);
                                    ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 33456 KB Output is correct
2 Correct 0 ms 33456 KB Output is correct
3 Correct 0 ms 33456 KB Output is correct
4 Correct 0 ms 33456 KB Output is correct
5 Correct 0 ms 33456 KB Output is correct
6 Correct 0 ms 33456 KB Output is correct
7 Correct 0 ms 33456 KB Output is correct
8 Correct 0 ms 33456 KB Output is correct
9 Correct 0 ms 33456 KB Output is correct
10 Correct 0 ms 33456 KB Output is correct
11 Correct 0 ms 33456 KB Output is correct
12 Correct 0 ms 33456 KB Output is correct
13 Correct 0 ms 33456 KB Output is correct
14 Correct 0 ms 33456 KB Output is correct
15 Correct 0 ms 33456 KB Output is correct
16 Correct 0 ms 33456 KB Output is correct
17 Correct 0 ms 33456 KB Output is correct
18 Correct 0 ms 33456 KB Output is correct
19 Correct 0 ms 33456 KB Output is correct
20 Correct 0 ms 33456 KB Output is correct
21 Correct 0 ms 33456 KB Output is correct
22 Correct 0 ms 33456 KB Output is correct
23 Correct 0 ms 33456 KB Output is correct
24 Correct 0 ms 33456 KB Output is correct
25 Correct 0 ms 33456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 33456 KB Output is correct
2 Correct 0 ms 33456 KB Output is correct
3 Correct 0 ms 33456 KB Output is correct
4 Correct 0 ms 33456 KB Output is correct
5 Correct 0 ms 33456 KB Output is correct
6 Correct 0 ms 33456 KB Output is correct
7 Correct 0 ms 33456 KB Output is correct
8 Correct 6 ms 33456 KB Output is correct
9 Correct 3 ms 33456 KB Output is correct
10 Correct 6 ms 33456 KB Output is correct
11 Correct 9 ms 33456 KB Output is correct
12 Correct 16 ms 33456 KB Output is correct
13 Correct 13 ms 33456 KB Output is correct
14 Correct 13 ms 33456 KB Output is correct
15 Correct 13 ms 33456 KB Output is correct
16 Correct 19 ms 33456 KB Output is correct
17 Correct 19 ms 33456 KB Output is correct
18 Correct 9 ms 33456 KB Output is correct
19 Correct 13 ms 33456 KB Output is correct
20 Correct 13 ms 33456 KB Output is correct
21 Correct 23 ms 33456 KB Output is correct
22 Correct 19 ms 33456 KB Output is correct
23 Correct 13 ms 33456 KB Output is correct
24 Correct 13 ms 33456 KB Output is correct
25 Correct 16 ms 33456 KB Output is correct
26 Correct 13 ms 33456 KB Output is correct
27 Correct 16 ms 33456 KB Output is correct
28 Correct 16 ms 33456 KB Output is correct
29 Correct 16 ms 33456 KB Output is correct
30 Correct 19 ms 33456 KB Output is correct
31 Correct 19 ms 33456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 33456 KB Output is correct
2 Correct 0 ms 33456 KB Output is correct
3 Correct 0 ms 33456 KB Output is correct
4 Correct 0 ms 33456 KB Output is correct
5 Correct 0 ms 33456 KB Output is correct
6 Correct 0 ms 33456 KB Output is correct
7 Correct 0 ms 33456 KB Output is correct
8 Correct 0 ms 33456 KB Output is correct
9 Correct 9 ms 33456 KB Output is correct
10 Correct 3 ms 33456 KB Output is correct
11 Correct 6 ms 33456 KB Output is correct
12 Correct 3 ms 33456 KB Output is correct
13 Correct 3 ms 33456 KB Output is correct
14 Correct 6 ms 33456 KB Output is correct
15 Correct 6 ms 33456 KB Output is correct
16 Correct 6 ms 33456 KB Output is correct
17 Correct 16 ms 33456 KB Output is correct
18 Correct 13 ms 33456 KB Output is correct
19 Correct 26 ms 33456 KB Output is correct
20 Correct 19 ms 33456 KB Output is correct
21 Correct 13 ms 33456 KB Output is correct
22 Correct 19 ms 33456 KB Output is correct
23 Correct 13 ms 33456 KB Output is correct
24 Correct 26 ms 33456 KB Output is correct
25 Correct 9 ms 33456 KB Output is correct
26 Correct 13 ms 33456 KB Output is correct
27 Correct 16 ms 33456 KB Output is correct
28 Correct 19 ms 33456 KB Output is correct
29 Correct 9 ms 33456 KB Output is correct
30 Correct 23 ms 33456 KB Output is correct
31 Correct 19 ms 33456 KB Output is correct
32 Correct 19 ms 33456 KB Output is correct
33 Correct 16 ms 33456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 33456 KB Output is correct
2 Correct 9 ms 33456 KB Output is correct
3 Correct 9 ms 33456 KB Output is correct
4 Correct 29 ms 33456 KB Output is correct
5 Correct 19 ms 33456 KB Output is correct
6 Correct 16 ms 33456 KB Output is correct
7 Correct 16 ms 33456 KB Output is correct
8 Correct 19 ms 33456 KB Output is correct
9 Correct 13 ms 33456 KB Output is correct
10 Correct 13 ms 33456 KB Output is correct
11 Correct 16 ms 33456 KB Output is correct
12 Correct 13 ms 33456 KB Output is correct
13 Correct 16 ms 33456 KB Output is correct
14 Correct 16 ms 33456 KB Output is correct
15 Correct 16 ms 33456 KB Output is correct
16 Correct 16 ms 33456 KB Output is correct
17 Correct 13 ms 33456 KB Output is correct
18 Correct 19 ms 33456 KB Output is correct
19 Correct 16 ms 33456 KB Output is correct
20 Correct 19 ms 33456 KB Output is correct
21 Correct 16 ms 33456 KB Output is correct
22 Correct 23 ms 33456 KB Output is correct
23 Correct 13 ms 33456 KB Output is correct
24 Correct 19 ms 33456 KB Output is correct
25 Correct 13 ms 33456 KB Output is correct