이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef int64_t lld;
typedef pair<int, int> pii;
array<array<int, 5000>, 5000> ans;
vector<int> v;
signed main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
int a; cin >> a;
v.pb(a);
}
for(int i = 0; i < n; i++)
for(int j = i+2, mx = -1; j < n; j++) {
if((i+j)%2 == 0) mx = max(mx, v[i+j>>1]);
ans[i][j] = v[i]+v[j]+mx;
}
for(int l = 3; l < n; l++)
for(int i = 0, j = l; j < n; i++, j++)
ans[i][j] = max({ans[i][j], ans[i+1][j], ans[i][j-1]});
int q;
cin >> q;
while(q--){
int a, b; cin >> a >> b; cout << ans[a-1][b-1] << endl;
}
}
컴파일 시 표준 에러 (stderr) 메시지
jumps.cpp: In function 'int main()':
jumps.cpp:22:40: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
22 | if((i+j)%2 == 0) mx = max(mx, v[i+j>>1]);
| ~^~| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |