Submission #200643

#TimeUsernameProblemLanguageResultExecution timeMemory
200643tincamatei3단 점프 (JOI19_jumps)C++14
19 / 100
913 ms144120 KiB
#include <bits/stdc++.h> using namespace std; const int MAX_N = 5000; int v[1+MAX_N], maxRange[1+MAX_N][1+MAX_N], dp[1+MAX_N][1+MAX_N]; int main() { int N, Q; scanf("%d", &N); for(int i = 1; i <= N; ++i) { scanf("%d", &v[i]); for(int j = i; j >= 1; --j) maxRange[j][i] = max(maxRange[j + 1][i], v[j]); } for(int d = 3; d <= N; ++d) for(int i = 1; i + d - 1 <= N; ++i) { int j = i + d - 1; dp[i][j] = max(v[i] + v[j] + maxRange[i + 1][(i + j) / 2], max(dp[i + 1][j], dp[i][j - 1])); } scanf("%d", &Q); for(int i = 0; i < Q; ++i) { int l, r; scanf("%d%d", &l, &r); printf("%d\n", dp[l][r]); } return 0; }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &N);
  ~~~~~^~~~~~~~~~
jumps.cpp:14:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v[i]);
   ~~~~~^~~~~~~~~~~~~
jumps.cpp:26:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d", &Q);
  ~~~~~^~~~~~~~~~
jumps.cpp:29:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &l, &r);
   ~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...