QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#48947#2283. Decelerating JumpcalrareTL 2993ms74104kbC++998b2022-09-18 03:38:242022-09-18 03:38:26

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-09-18 03:38:26]
  • 评测
  • 测评结果:TL
  • 用时:2993ms
  • 内存:74104kb
  • [2022-09-18 03:38:24]
  • 提交

answer

/*
Decelerating Jump
https://qoj.ac/problem/2283

DP

*/

#include <cstdio>
#include <iostream>

using namespace std;

int sqr[3005];
long long mem[3005][3005];

long long solve(int i, int maxi, int n){
  //printf("Proc %d, %d\n", i, maxi);
  long long ans = -1e15, aux;
  int k;

  if(mem[i][maxi] != -1e15)
    ans = mem[i][maxi];
  else{
    if(i == n - 1)
      ans = sqr[i];
    else{
      //printf("Aca %d, %d\n");
      for(k = i + 1; k <= min(n - 1, i + maxi); ++k){
	aux = solve(k, k - i, n);
	if(aux != -1e15){
	  ans = max(ans, aux + sqr[i]);
	  //printf("Mejor ahora %d, %d es %lli\n", i, maxi, ans);
	}
      }
    }

    mem[i][maxi] = ans;

    //printf("Res %d, %d, %lli\n", i, maxi, ans);
  }
   
  return ans;
}

int main(){
  int i, j, n;
  long long ans;
  scanf("%d", &n);
  for(i = 0; i < n; ++i)
    scanf("%d", sqr + i);
  for(i = 0; i < n + 1; ++i)
    for(j = 0; j < n + 1; ++j)
      mem[i][j] = -1e15;
  ans = solve(0, n - 1, n);
  printf("%lli\n", ans);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 85ms
memory: 15544kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

2

result:

ok single line: '2'

Test #2:

score: 0
Accepted
time: 82ms
memory: 15616kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

3

result:

ok single line: '3'

Test #3:

score: 0
Accepted
time: 82ms
memory: 15576kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

7

result:

ok single line: '7'

Test #4:

score: 0
Accepted
time: 77ms
memory: 15628kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

12

result:

ok single line: '12'

Test #5:

score: 0
Accepted
time: 82ms
memory: 15620kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...

output:

27

result:

ok single line: '27'

Test #6:

score: 0
Accepted
time: 79ms
memory: 15632kb

input:

1000
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0...

output:

35

result:

ok single line: '35'

Test #7:

score: 0
Accepted
time: 2ms
memory: 3748kb

input:

2
0 0

output:

0

result:

ok single line: '0'

Test #8:

score: 0
Accepted
time: 2ms
memory: 3804kb

input:

2
-1 -9

output:

-10

result:

ok single line: '-10'

Test #9:

score: 0
Accepted
time: 2ms
memory: 3748kb

input:

10
-1 0 1 0 0 0 1 1 1 -1

output:

2

result:

ok single line: '2'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3768kb

input:

20
-2 -2 -1 -1 -2 1 0 1 2 3 -1 2 1 3 2 3 -1 -2 -1 3

output:

14

result:

ok single line: '14'

Test #11:

score: 0
Accepted
time: 2ms
memory: 3888kb

input:

10
3 10 -2 -9 4 -7 5 -7 -4 -5

output:

3

result:

ok single line: '3'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3904kb

input:

50
-8 -3 -9 -9 -4 -8 7 -4 -10 -4 8 -9 -6 1 7 2 0 -3 7 3 -7 -9 -9 -9 6 -7 -2 -10 2 8 -10 -5 6 -4 -3 7 -8 -6 9 5 3 -4 9 1 10 8 0 -1 2 6

output:

82

result:

ok single line: '82'

Test #13:

score: 0
Accepted
time: 2ms
memory: 4228kb

input:

100
-64 65 -52 -25 39 -83 23 30 35 51 22 73 20 -18 -29 90 44 28 -34 -88 -79 -49 57 -63 86 -6 -92 28 44 41 73 8 -83 18 -25 40 29 87 50 22 -5 96 99 -74 60 -18 92 21 -65 -78 -17 -25 -8 49 69 -78 -82 92 83 -14 33 90 57 19 65 -50 -19 -77 74 -11 54 21 72 -55 -66 -43 -44 94 -27 46 -74 64 -8 -45 -78 14 -6 -...

output:

834

result:

ok single line: '834'

Test #14:

score: 0
Accepted
time: 3ms
memory: 4840kb

input:

200
-592 -939 223 74 -372 736 38 -455 735 -998 422 331 -740 142 38 -561 70 765 764 -839 -882 373 -174 938 -679 -33 596 98 -732 142 89 981 -743 -284 790 -289 -908 -830 -666 122 314 299 -192 545 119 -842 -113 934 -580 -72 60 -349 659 -562 885 835 629 -888 366 -245 -260 25 -193 683 -734 979 209 219 922...

output:

14459

result:

ok single line: '14459'

Test #15:

score: 0
Accepted
time: 5ms
memory: 5636kb

input:

300
-1282 5441 4865 -1420 -8118 6740 -2338 8435 -1095 3910 -9689 5258 -6414 8818 -1922 4168 6575 3345 -7739 -1709 -2456 -129 -9151 -4377 -9100 -1500 7944 9614 9380 -1510 4084 -3084 -3499 6851 -7316 7517 -172 1923 6690 -9334 639 -7411 55 -6105 4174 -7667 -9254 3848 -7194 9846 4137 -6914 -1023 6028 91...

output:

222431

result:

ok single line: '222431'

Test #16:

score: 0
Accepted
time: 7ms
memory: 7728kb

input:

500
-9312 3629 8352 -7728 5135 81 -959 251 -9992 -4873 6875 1153 2051 -559 7920 2726 9524 -2830 -4068 9650 -9989 3902 -4634 -4342 -6615 3225 -6581 -2189 -7899 8427 -8501 5663 -7532 -3316 -31 7085 912 7165 5484 5435 1439 9351 9059 1071 -7166 -7371 -6786 -2978 -1303 -2821 -90 827 -2934 -4066 6413 -265...

output:

334460

result:

ok single line: '334460'

Test #17:

score: 0
Accepted
time: 2993ms
memory: 74104kb

input:

2990
-970733755 373162926 610706002 746420415 -24022769 446900035 80395723 -518380142 727642894 -802578839 -299221072 790023549 812359052 558846138 816832324 987432334 802786331 -460777465 821945862 -928082137 -166432503 927724630 -663110602 304682374 -219146966 -229896662 -389891025 508234675 55873...

output:

92279083496

result:

ok single line: '92279083496'

Test #18:

score: -100
Time Limit Exceeded

input:

2999
-500871756 570771509 -197276377 -847066915 -566097239 289678269 -16423398 -512745365 947375427 359581421 -220058506 -704742619 714443677 606538047 -443765043 798590851 -808020275 306066404 -561778738 -713774588 -970747408 610730044 -364520383 -10370313 961430924 -631087201 732038986 -358099605 ...

output:


result: