Submission #797420

#TimeUsernameProblemLanguageResultExecution timeMemory
797420fatemetmhrTriple Jump (JOI19_jumps)C++17
19 / 100
307 ms87104 KiB
// Be name khoda // #include <bits/stdc++.h> #define all(x) x.begin(), x.end() #define pb push_back #define fi first #define se second #define mp make_pair typedef long long ll; using namespace std; const int maxn5 = 5e3 + 10; const int maxn = 1e6 + 10; const int lg = 20; const ll inf = 1e18; int a[maxn5], rmq[maxn5][maxn5]; ll mx[maxn5], out[maxn]; vector <pair<pair<int, int>, int>> req; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for(int i = 0; i < n; i++){ cin >> a[i]; rmq[i][i] = a[i]; } for(int i = 0; i < n; i++) for(int j = i + 1; j < n; j++) rmq[i][j] = max(rmq[i][j - 1], a[j]); int q; cin >> q; for(int i = 0; i < q; i++){ int l, r; cin >> l >> r; l--; r--; req.pb({{r, l}, i}); } sort(all(req)); int ind = 0; for(int i = 0; i < n; i++){ for(int j = i - 2; j >= 0; j--) mx[j] = max({mx[j + 1], mx[j], ll(a[j]) + a[i] + rmq[j + 1][(i + j) / 2]}); while(ind < req.size() && req[ind].fi.fi == i){ out[req[ind].se] = mx[req[ind].fi.se]; ind++; } } for(int i = 0; i < q; i++) cout << out[i] << '\n'; }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:45:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         while(ind < req.size() && req[ind].fi.fi == i){
      |               ~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...