#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=0;i<=n;i++)
{
for(j=2;j<=2000;j++)
{
d[i][j]=-2147483647;
}
}
for(i=1;i<=n;i++)
{
for(j=0;j<=2000;j++)
{
if(d[i-1][j]!=-2147483647)
{
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16884 KB |
Output is correct |
2 |
Incorrect |
0 ms |
16884 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16884 KB |
Output is correct |
2 |
Incorrect |
0 ms |
16884 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
16884 KB |
Output is correct |
2 |
Correct |
0 ms |
16884 KB |
Output is correct |
3 |
Incorrect |
0 ms |
16884 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
8 ms |
16884 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |