Submission #1013012

#TimeUsernameProblemLanguageResultExecution timeMemory
1013012Alihan_8Triple Jump (JOI19_jumps)C++17
5 / 100
4048 ms8644 KiB
#include <bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() #define ar array #define pb push_back #define ln '\n' #define int long long using i64 = long long; template <class F, class _S> bool chmin(F &u, const _S &v){ bool flag = false; if ( u > v ){ u = v; flag |= true; } return flag; } template <class F, class _S> bool chmax(F &u, const _S &v){ bool flag = false; if ( u < v ){ u = v; flag |= true; } return flag; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector <int> a(n); for ( auto &u: a ){ cin >> u; } int q; cin >> q; while ( q-- ){ int l, r; cin >> l >> r; --l, --r; vector <ar<int,2>> tmp; for ( int i = l; i <= r; i++ ){ tmp.pb({-a[i], i}); } sort(all(tmp)); vector <int> b; for ( int i = 0; i < min(n, (int)tmp.size()); i++ ){ b.pb(tmp[i][1]); } sort(all(b)); int opt = 0; for ( int i = 1; i + 1 < b.size(); i++ ){ for ( int j = 0; j < i; j++ ){ for ( int k = i + 1; k < b.size(); k++ ){ if ( b[i] - b[j] <= b[k] - b[i] ){ chmax(opt, a[b[i]] + a[b[j]] + a[b[k]]); } } } } cout << opt << ln; } cout << '\n'; }

Compilation message (stderr)

jumps.cpp: In function 'int main()':
jumps.cpp:68:32: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   68 |         for ( int i = 1; i + 1 < b.size(); i++ ){
      |                          ~~~~~~^~~~~~~~~~
jumps.cpp:70:40: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |                 for ( int k = i + 1; k < b.size(); k++ ){
      |                                      ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...