Submission #812154

#TimeUsernameProblemLanguageResultExecution timeMemory
812154vjudge1Triple Jump (JOI19_jumps)C++14
19 / 100
4041 ms143948 KiB
#include<bits/stdc++.h> #pragma comment(linker, "/stack:200000000") #pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") #define fi first #define se second #define ll long long using namespace std ; const int N = 5e5, NS = 5e3 ; int n, q, d[N + 1], dp[NS + 1][NS + 1], mx[NS + 1][NS + 1] ; signed main() { ios_base::sync_with_stdio( 0 ) ; cin.tie( 0 ) ; cout.tie( 0 ) ; cin >> n ; for(int i = 1 ; i <= n ; i++) cin >> d[i] ; cin >> q ; // if(n <= 5000) // { for(int i = 1 ; i <= n ; i++) for(int j = i ; j <= n ; j++) mx[i][j] = max(mx[i][j - 1], d[j]) ; for(int i = 1 ; i <= n - 2 ; i++) dp[i][i + 2] = d[i] + d[i + 1] + d[i + 2] ; for(int ln = 4 ; ln <= n ; ln++) for(int j = 1 ; j <= n - ln + 1 ; j++) dp[j][j + ln - 1] = max({dp[j][j + ln - 2], dp[j + 1][j + ln - 1], d[j] + d[j + ln - 1] + mx[j + 1][j + (ln - 1) / 2]}) ; while(q--) { int l, r ; cin >> l >> r ; cout << dp[l][r] << '\n' ; } return 0 ; // } return 0 ; }

Compilation message (stderr)

jumps.cpp:2: warning: ignoring '#pragma comment ' [-Wunknown-pragmas]
    2 | #pragma comment(linker, "/stack:200000000")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...