제출 #677801

#제출 시각아이디문제언어결과실행 시간메모리
677801qwerasdfzxclTriple Jump (JOI19_jumps)C++17
19 / 100
497 ms144304 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; int a[5050], ans[5050][5050], dp[5050][5050]; int main(){ int n; scanf("%d", &n); for (int i=1;i<=n;i++) scanf("%d", a+i); for (int i=1;i<=n;i++){ int pt = i, val = 0; for (int j=i+2;j<=n;j++){ if (pt+1 - i <= j - (pt+1)){ ++pt; val = max(val, a[pt]); } ans[i][j] = a[i] + a[j] + val; } } for (int d=2;d<n;d++){ for (int i=1;i<=n-d;i++){ int j = i+d; dp[i][j] = max(ans[i][j], max(dp[i+1][j], dp[i][j-1])); } } int q; scanf("%d", &q); while(q--){ int x, y; scanf("%d %d", &x, &y); printf("%d\n", dp[x][y]); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

jumps.cpp: In function 'int main()':
jumps.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:10:33: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     for (int i=1;i<=n;i++) scanf("%d", a+i);
      |                            ~~~~~^~~~~~~~~~~
jumps.cpp:31:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |     scanf("%d", &q);
      |     ~~~~~^~~~~~~~~~
jumps.cpp:34:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |         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...