Submission #812474

#TimeUsernameProblemLanguageResultExecution timeMemory
812474vjudge1Triple Jump (JOI19_jumps)C++17
19 / 100
249 ms72376 KiB
#ifdef Home #define _GLIBCXX_DEBUG #endif // Home #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; const int N = 5005; int mx[N][N], arr[N]; main() { #ifdef Home freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif // Home ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; for(int i = 1; i <= n; ++ i) { cin >> arr[i]; } for(int l = n; l >= 1; -- l) { int m = l + 1; for(int r = m + 1; r <= n; ++ r) { if(m < (l + r) / 2 && arr[m] < arr[(l + r) / 2]) { m = (l + r) / 2; } mx[l][r] = max({mx[l + 1][r], mx[l][r - 1], arr[l] + arr[m] + arr[r]}); } } int q, l, r; for(cin >> q; q --> 0;) { cin >> l >> r; cout << mx[l][r] << '\n'; } }

Compilation message (stderr)

jumps.cpp:17:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main() {
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...