제출 #515448

#제출 시각아이디문제언어결과실행 시간메모리
51544879brue3단 점프 (JOI19_jumps)C++14
0 / 100
4042 ms964 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, q; int arr[500002]; int DP[5002][5002]; int DPmax[5002][5002]; int main(){ scanf("%d", &n); for(int i=1; i<=n; i++) scanf("%d", &arr[i]); scanf("%d", &q); while(q--){ int l, r; scanf("%d %d", &l, &r); int ans = 0; for(int b=l+1; b<r; b++){ int aMax = 0, aVal = -1; for(int a=max(l, 2*b-r); a<b; a++){ if(aVal <= arr[a]) aMax = a, aVal = arr[a]; } for(int c=b+1; c<=r; c++) if(b-aMax <= c-b) ans = max(ans, arr[aMax] + arr[b] + arr[c]); int cMax = 0, cVal = -1; for(int c=b+1; c<=r; c++){ if(cVal <= arr[c]) cMax = c, cVal = arr[c]; } for(int a=l; a<b; a++) if(b-a <= cMax-b) ans = max(ans, arr[a] + arr[b] + arr[cMax]); } printf("%d\n", ans); } }

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

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