Submission #1103036

# Submission time Handle Problem Language Result Execution time Memory
1103036 2024-10-19T14:47:50 Z duonggsimp Triple Jump (JOI19_jumps) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define xn '\n'
#define pb push_back
#define oo LONG_MAX
using namespace std;

typedef pair<ll,ll> i2;
typedef pair<ll,i2> i3;
typedef pair<i2,ll> i4;

const int N = 1e5+5;
const int M = 1e3+5;
const ll mo = 1e9+7;

ll n,m;
ll a[N];
ll c[N];
ll d[N];
ll res;
stack <ll> s;

void sub3(){
    ll l,r; cin >> l >> r;
    for (long i=n; i>=1; i--) c[i] = max(c[i+1],a[i]);
    for (long i=1; i<=n; i++){
        ll j1 = 0;
        while (!s.empty() && a[i] > a[s.top()]) s.pop();
        if (!s.empty()) j1 = s.top();
        res = max(res,a[j1]+a[i]+c[i+i-j1]);
        s.push(i);
    }

    cout << res;
}

void sub1(){
    while (m--){
        ll l,r; cin >> l >> r;
        ll ans = 0;
        for (long i=l; i<=r-2 ; i++){
            for (long j=i 1 ; j<=r-1 ; j++){
                for (long k=j+(j - i); k<=r ; k++){
                ans = max(ans , a[i] + a[j] + a[k]);
            }
        }
    }
    cout << ans << xn;
    }
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;
    for (long i=1; i<=n; i++) cin >> a[i];
    cin >> m;
    if (m == 1) sub3(); else sub1();
    return 0;
}

Compilation message

jumps.cpp: In function 'void sub1()':
jumps.cpp:44:26: error: expected ';' before numeric constant
   44 |             for (long j=i 1 ; j<=r-1 ; j++){
      |                          ^~
      |                          ;
jumps.cpp:44:32: warning: for increment expression has no effect [-Wunused-value]
   44 |             for (long j=i 1 ; j<=r-1 ; j++){
      |                               ~^~~~~
jumps.cpp:44:37: error: expected ')' before ';' token
   44 |             for (long j=i 1 ; j<=r-1 ; j++){
      |                 ~                   ^~
      |                                     )
jumps.cpp:44:13: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |             for (long j=i 1 ; j<=r-1 ; j++){
      |             ^~~
jumps.cpp:44:40: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |             for (long j=i 1 ; j<=r-1 ; j++){
      |                                        ^
jumps.cpp:44:40: error: 'j' was not declared in this scope