Submission #1243989

#TimeUsernameProblemLanguageResultExecution timeMemory
1243989snowysmoWatching (JOI13_watching)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'

using namespace std;

const int mx = 2e5+7;
ll n, p, q, a[mx];
bool check(ll x){
    ll a=p, b=q;
    bool cn=1;
    for(ll i=1;i<=n;i++){
        ll xx=a[i+1]-a[i]+1, yy=a[i+2]-a[i]+1;
        if(2*x-yy >= x-xx && x!=0) x--, i++;
        else if(2*x-yy >= x-xx && x==0) y--, i+=2;
        else if(2*x-yy < x-xx && y!=0) y--, i+=2;
        else if(2*x-yy < x-xx && y==0) x--, i++;
        else{ cn=0; break; }
    }
    return cn;
}
ll binser(ll l, ll r){
    ll mid, ans=1e9+7;
    while(l<=r){
        mid=(l+r)/2;
        if(check(mid)) ans=min(ans, mid), r=mid-1;
        else l=mid+1;
    }
    return ans;
}
int main(){
    cin>>n>>p>>q;
    ll temp = p+2*q;
    ll ans=0;
    for(ll i=1;i<=n;i++) cin>>a[i];
    for(ll i=2;i<=n;i++) ans+=abs(a[i]-a[i-1]);
    ll x = ans/temp+1;
    cout<<binser(1, x)<<endl;


    return 0;
}

Compilation message (stderr)

watching.cpp: In function 'bool check(long long int)':
watching.cpp:13:16: error: invalid types 'long long int[long long int]' for array subscript
   13 |         ll xx=a[i+1]-a[i]+1, yy=a[i+2]-a[i]+1;
      |                ^
watching.cpp:13:23: error: invalid types 'long long int[long long int]' for array subscript
   13 |         ll xx=a[i+1]-a[i]+1, yy=a[i+2]-a[i]+1;
      |                       ^
watching.cpp:14:16: error: 'yy' was not declared in this scope; did you mean 'yn'?
   14 |         if(2*x-yy >= x-xx && x!=0) x--, i++;
      |                ^~
      |                yn
watching.cpp:15:41: error: 'y' was not declared in this scope
   15 |         else if(2*x-yy >= x-xx && x==0) y--, i+=2;
      |                                         ^
watching.cpp:16:34: error: 'y' was not declared in this scope
   16 |         else if(2*x-yy < x-xx && y!=0) y--, i+=2;
      |                                  ^