Submission #8241

# Submission time Handle Problem Language Result Execution time Memory
8241 2014-09-07T14:25:26 Z dohyun0324 스트랩 (JOI14_straps) C++
100 / 100
28 ms 16884 KB
#include<stdio.h>
#include<algorithm>
using namespace std;
int dap,n,a[2010],b[2010],d[2010][2010];
int main()
{
    int i,j;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&a[i],&b[i]);
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            if(a[i]>a[j])
            {
                swap(a[i],a[j]); swap(b[i],b[j]);
            }
        }
    }
    for(i=0;i<=n;i++)
    {
        for(j=2;j<=2000;j++)
        {
            d[i][j]=-2147483647;
        }
        d[i][0]=-2147483647;
    }
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=2000;j++)
        {
            if(d[i-1][j]!=-2147483647)
            {
                if(j!=0) d[i][min(2000,j+a[i]-1)]=max(d[i][min(2000,j+a[i]-1)],d[i-1][j]+b[i]);
                d[i][j]=max(d[i][j],d[i-1][j]);
            }
        }
    }
    for(i=0;i<=2000;i++)
    {
        if(dap<d[n][i]) dap=d[n][i];
    }
    printf("%d",dap);
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16884 KB Output is correct
2 Correct 0 ms 16884 KB Output is correct
3 Correct 0 ms 16884 KB Output is correct
4 Correct 0 ms 16884 KB Output is correct
5 Correct 0 ms 16884 KB Output is correct
6 Correct 0 ms 16884 KB Output is correct
7 Correct 0 ms 16884 KB Output is correct
8 Correct 0 ms 16884 KB Output is correct
9 Correct 0 ms 16884 KB Output is correct
10 Correct 0 ms 16884 KB Output is correct
11 Correct 0 ms 16884 KB Output is correct
12 Correct 0 ms 16884 KB Output is correct
13 Correct 0 ms 16884 KB Output is correct
14 Correct 0 ms 16884 KB Output is correct
15 Correct 0 ms 16884 KB Output is correct
16 Correct 0 ms 16884 KB Output is correct
17 Correct 0 ms 16884 KB Output is correct
18 Correct 0 ms 16884 KB Output is correct
19 Correct 0 ms 16884 KB Output is correct
20 Correct 0 ms 16884 KB Output is correct
21 Correct 0 ms 16884 KB Output is correct
22 Correct 0 ms 16884 KB Output is correct
23 Correct 0 ms 16884 KB Output is correct
24 Correct 0 ms 16884 KB Output is correct
25 Correct 0 ms 16884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16884 KB Output is correct
2 Correct 0 ms 16884 KB Output is correct
3 Correct 0 ms 16884 KB Output is correct
4 Correct 0 ms 16884 KB Output is correct
5 Correct 0 ms 16884 KB Output is correct
6 Correct 0 ms 16884 KB Output is correct
7 Correct 0 ms 16884 KB Output is correct
8 Correct 4 ms 16884 KB Output is correct
9 Correct 4 ms 16884 KB Output is correct
10 Correct 4 ms 16884 KB Output is correct
11 Correct 8 ms 16884 KB Output is correct
12 Correct 16 ms 16884 KB Output is correct
13 Correct 4 ms 16884 KB Output is correct
14 Correct 16 ms 16884 KB Output is correct
15 Correct 8 ms 16884 KB Output is correct
16 Correct 12 ms 16884 KB Output is correct
17 Correct 8 ms 16884 KB Output is correct
18 Correct 4 ms 16884 KB Output is correct
19 Correct 12 ms 16884 KB Output is correct
20 Correct 12 ms 16884 KB Output is correct
21 Correct 24 ms 16884 KB Output is correct
22 Correct 16 ms 16884 KB Output is correct
23 Correct 20 ms 16884 KB Output is correct
24 Correct 16 ms 16884 KB Output is correct
25 Correct 24 ms 16884 KB Output is correct
26 Correct 20 ms 16884 KB Output is correct
27 Correct 16 ms 16884 KB Output is correct
28 Correct 16 ms 16884 KB Output is correct
29 Correct 20 ms 16884 KB Output is correct
30 Correct 16 ms 16884 KB Output is correct
31 Correct 24 ms 16884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 16884 KB Output is correct
2 Correct 0 ms 16884 KB Output is correct
3 Correct 0 ms 16884 KB Output is correct
4 Correct 0 ms 16884 KB Output is correct
5 Correct 0 ms 16884 KB Output is correct
6 Correct 0 ms 16884 KB Output is correct
7 Correct 0 ms 16884 KB Output is correct
8 Correct 0 ms 16884 KB Output is correct
9 Correct 4 ms 16884 KB Output is correct
10 Correct 4 ms 16884 KB Output is correct
11 Correct 8 ms 16884 KB Output is correct
12 Correct 8 ms 16884 KB Output is correct
13 Correct 4 ms 16884 KB Output is correct
14 Correct 8 ms 16884 KB Output is correct
15 Correct 4 ms 16884 KB Output is correct
16 Correct 4 ms 16884 KB Output is correct
17 Correct 16 ms 16884 KB Output is correct
18 Correct 8 ms 16884 KB Output is correct
19 Correct 8 ms 16884 KB Output is correct
20 Correct 4 ms 16884 KB Output is correct
21 Correct 8 ms 16884 KB Output is correct
22 Correct 8 ms 16884 KB Output is correct
23 Correct 8 ms 16884 KB Output is correct
24 Correct 12 ms 16884 KB Output is correct
25 Correct 8 ms 16884 KB Output is correct
26 Correct 16 ms 16884 KB Output is correct
27 Correct 8 ms 16884 KB Output is correct
28 Correct 8 ms 16884 KB Output is correct
29 Correct 8 ms 16884 KB Output is correct
30 Correct 8 ms 16884 KB Output is correct
31 Correct 12 ms 16884 KB Output is correct
32 Correct 4 ms 16884 KB Output is correct
33 Correct 8 ms 16884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 16884 KB Output is correct
2 Correct 20 ms 16884 KB Output is correct
3 Correct 12 ms 16884 KB Output is correct
4 Correct 8 ms 16884 KB Output is correct
5 Correct 20 ms 16884 KB Output is correct
6 Correct 20 ms 16884 KB Output is correct
7 Correct 20 ms 16884 KB Output is correct
8 Correct 20 ms 16884 KB Output is correct
9 Correct 24 ms 16884 KB Output is correct
10 Correct 20 ms 16884 KB Output is correct
11 Correct 24 ms 16884 KB Output is correct
12 Correct 28 ms 16884 KB Output is correct
13 Correct 20 ms 16884 KB Output is correct
14 Correct 20 ms 16884 KB Output is correct
15 Correct 24 ms 16884 KB Output is correct
16 Correct 20 ms 16884 KB Output is correct
17 Correct 20 ms 16884 KB Output is correct
18 Correct 16 ms 16884 KB Output is correct
19 Correct 20 ms 16884 KB Output is correct
20 Correct 16 ms 16884 KB Output is correct
21 Correct 20 ms 16884 KB Output is correct
22 Correct 12 ms 16884 KB Output is correct
23 Correct 16 ms 16884 KB Output is correct
24 Correct 16 ms 16884 KB Output is correct
25 Correct 12 ms 16884 KB Output is correct