Submission #1007966

#TimeUsernameProblemLanguageResultExecution timeMemory
1007966Rolo678Triple Jump (JOI19_jumps)C++14
5 / 100
4072 ms15516 KiB
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int>a(n+1); for(int i = 1;i<=n;i++) { cin >> a[i]; } vector<vector<pair<int,int>>>p(n+1); for(int i = 1;i<=n;i++) { int mx = 0; for(int j = i+1;j<=n;j++) { if(a[j] >= mx ) { p[i].push_back({a[j],j}); } mx = max(a[j],mx); } } int q; cin >> q; while(q--) { int l,r; cin >> l >> r; long long ans = 0; int a1,b,c; for(int i = l;i<=r-2;i++) { for(auto j :p[i]) { if(j.second > r-1) { continue; } for(int k = 2*(j.second) - i;k <= r;k++) { if(k<1 || !(k -j.second >= j.second - i )|| k <=j.second || k<=i) { continue; } ans = max(ans,(long long)(a[i]+j.first+a[k])); } } } cout << ans <<'\n'; } }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:35:13: warning: unused variable 'a1' [-Wunused-variable]
   35 |         int a1,b,c;
      |             ^~
jumps.cpp:35:16: warning: unused variable 'b' [-Wunused-variable]
   35 |         int a1,b,c;
      |                ^
jumps.cpp:35:18: warning: unused variable 'c' [-Wunused-variable]
   35 |         int a1,b,c;
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...