제출 #941677

#제출 시각아이디문제언어결과실행 시간메모리
941677PlayVoltz3단 점프 (JOI19_jumps)C++17
0 / 100
15 ms1884 KiB
#include <iostream> #include <map> #include <vector> #include <climits> #include <stack> #include <string> #include <queue> #include <algorithm> #include <set> #include <unordered_set> #include <unordered_map> #include <cmath> #include <cctype> #include <bitset> #include <iomanip> #include <cstring> #include <numeric> using namespace std; #define int long long #define pb push_back #define mp make_pair #define pii pair<int, int> #define fi first #define se second int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, q, a, b; cin>>n; vector<int> vect(n+1); for (int i=1; i<=n; ++i)cin>>vect[i]; cin>>q; while (q--){ cin>>a>>b; int res=0; for (int i=b, j=b, p=b, best=0, mx=0; i>=a; --i){ best=0; while (j>i){ while (p>=2*j-i)mx=max(mx, vect[p]), --p; best=max(best, vect[j]+mx); --j; } res=max(res, vect[i]+best); } cout<<res<<"\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...