Submission #135535

#TimeUsernameProblemLanguageResultExecution timeMemory
135535KLPP3단 점프 (JOI19_jumps)C++14
19 / 100
2625 ms451112 KiB
#include<bits/stdc++.h> using namespace std; typedef long long int lld; #define rep(i,a,b) for(int i=a;i<b;i++) lld SG[5000][5000]; bool visited[5000][5000]; lld compute(int i, int j){ if(visited[i][j])return SG[i][j]; SG[i][j]=max(SG[i][j],compute(i+1,j)); SG[i][j]=max(SG[i][j],compute(i,j-1)); visited[i][j]=true; return SG[i][j]; } int main(){ int n,q; scanf("%d",&n); lld arr[n]; rep(i,0,n)scanf("%lld",&arr[i]); scanf("%d",&q); rep(i,0,n){ rep(j,0,n)SG[i][j]=0,visited[i][j]=false; } rep(i,0,n-2){ visited[i][i+2]=true; } rep(i,0,n){ lld B=arr[i+1]; rep(j,i+2,n){ B=max(B,arr[(i+j)/2]); SG[i][j]=max(SG[i][j],arr[i]+B+arr[j]); } } while(q--){ int x,y; scanf("%d %d",&x,&y); x--;y--; printf("%lld\n",compute(x,y)); } return 0; }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:17:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&n);
   ~~~~~^~~~~~~~~
jumps.cpp:19:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   rep(i,0,n)scanf("%lld",&arr[i]);
             ~~~~~^~~~~~~~~~~~~~~~
jumps.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&q);
   ~~~~~^~~~~~~~~
jumps.cpp:37:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&x,&y);
     ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...