Submission #765076

# Submission time Handle Problem Language Result Execution time Memory
765076 2023-06-24T08:16:24 Z Kryz Watching (JOI13_watching) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fi first
#define se second
#define sst string
#define pb push_back
#define maxco 100000+5
#define lld long double
#define cha ios_base::sync_with_stdio(false);
#define ffl cout.flush();
#define phi acos(-1)
#define mod 707
#define mr make_pair
#define pqin priority_queue<ll,vector<ll>,greater<>>
#define pqpair priority_queue<pair<ll,ll> ,vector<pair<ll,ll>>,greater<pair<ll,ll>>>
#define pqpair2 priority_queue<pair<pair<ll,ll>,pair<ll,ll>>,vector<pair<pi,pair<ll,ll>>>,greater<pair<pi,pair<ll,ll>>>>
#define INF 1000000009
#define MAXN 500069
#define pi pair<ll,ll>
ll mvx[]={1,-1,0,0};
ll mvy[]={0,0,1,-1};

pair<ll,ll> pr[MAXN];
ll ps[MAXN];
int main(){
    ll n;
    cin>>n;
    set<ll> st;
    for(ll i=1;i<=n;i++){
        cin>>pr[i].fi>>pr[i].se;
    }
    sort(pr+1,pr+n+1);
    ll mk=0;
    ll idx;
    for(ll i=1;ijavascript:tab_clicked(1)<=n;i++){
        ps[i]+=ps[i-1]+pr[i].se;
        if(ps[i]-pr[i].fi>mk){
            mk=ps[i]-pr[i].fi;
            idx=i;
        }
    }
    ll ans=0;
    for(ll i=1;i<=idx;i++){
        ans=max(ans,pr[i].fi+ps[idx]-ps[i-1]-pr[idx].fi);
    }
    for(ll i=1;i<=n;i++){
        ans=max(ans,pr[i].se);
    }
    cout<<ans<<endl;
}

Compilation message

watching.cpp: In function 'int main()':
watching.cpp:36:16: warning: range-based 'for' loops with initializer only available with '-std=c++2a' or '-std=gnu++2a'
   36 |     for(ll i=1;ijavascript:tab_clicked(1)<=n;i++){
      |                ^~~~~~~~~~~
watching.cpp:36:27: error: found ':' in nested-name-specifier, expected '::'
   36 |     for(ll i=1;ijavascript:tab_clicked(1)<=n;i++){
      |                           ^
      |                           ::
watching.cpp:36:16: error: 'ijavascript' has not been declared
   36 |     for(ll i=1;ijavascript:tab_clicked(1)<=n;i++){
      |                ^~~~~~~~~~~
watching.cpp:36:49: error: expected ';' before ')' token
   36 |     for(ll i=1;ijavascript:tab_clicked(1)<=n;i++){
      |                                                 ^
      |                                                 ;