Submission #1151564

#TimeUsernameProblemLanguageResultExecution timeMemory
1151564hashimaliBikeparking (EGOI24_bikeparking)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #define endl '\n'
#define ld long double
#define pb push_back
#define pf push_front
#define mod 10000007
#define se second
#define fi first
#define all(ls) (ls).begin(),(ls).end()
#define int long long
using namespace std;
using namespace __gnu_pbds;
template<typename type>using ordered_set=tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename type>using ordered_multiset=tree<type,null_type,less_equal<type>,rb_tree_tag,tree_order_statistics_node_update>;
void solve(){
    int n,ans=0;
    cin>>n;
    set<int>pos;
    int a[n],b[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>0)
            pos.insert(i);
    }
    for(int i=0;i<n;i++)
        cin>>b[i];
    int i=0;
    while(pos.size() and i<n)
        auto lb=pos.lower_bound(i);
        if(lb!=pos.begin()){
            lb--;
            int tmp=min(a[*lb],b[i]);
            ans+=tmp;
            a[*lb]-=tmp;
            b[i]-=tmp;
            if(a[*lb]==0)
                pos.erase(lb);
            if(b[i]==0)
                i++;
        }
        else
            i++;
    }
    for(int i=0;i<n;i++)
        if(pos.count(i))
            ans-=max(0LL,b[i]-a[i]);
        else
            ans-=b[i];
    cout<<ans<<endl;
}  
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    for(int i=1;i<=t;i++){
        // cout<<"Scenario #"<<i<<":"<<" ";
        solve();
    }
}

Compilation message (stderr)

Main.cpp: In function 'void solve()':
Main.cpp:32:12: error: 'lb' was not declared in this scope; did you mean 'b'?
   32 |         if(lb!=pos.begin()){
      |            ^~
      |            b
Main.cpp: At global scope:
Main.cpp:46:5: error: expected unqualified-id before 'for'
   46 |     for(int i=0;i<n;i++)
      |     ^~~
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   46 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:46:17: error: 'i' does not name a type; did you mean 'fi'?
   46 |     for(int i=0;i<n;i++)
      |                 ^
      |                 fi
Main.cpp:46:21: error: 'i' does not name a type; did you mean 'fi'?
   46 |     for(int i=0;i<n;i++)
      |                     ^
      |                     fi
Main.cpp:49:9: error: expected unqualified-id before 'else'
   49 |         else
      |         ^~~~
Main.cpp:51:5: error: 'cout' does not name a type
   51 |     cout<<ans<<endl;
      |     ^~~~
Main.cpp:52:1: error: expected declaration before '}' token
   52 | }
      | ^