Submission #1151563

#TimeUsernameProblemLanguageResultExecution timeMemory
1151563hashimaliBikeparking (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]; 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:29:26: error: 'i' was not declared in this scope
   29 |     while(pos.size() and i<n)
      |                          ^
Main.cpp:31:12: error: 'lb' was not declared in this scope; did you mean 'b'?
   31 |         if(lb!=pos.begin()){
      |            ^~
      |            b
Main.cpp:33:34: error: 'i' was not declared in this scope
   33 |             int tmp=min(a[*lb],b[i]);
      |                                  ^
Main.cpp:43:13: error: 'i' was not declared in this scope
   43 |             i++;
      |             ^
Main.cpp: At global scope:
Main.cpp:45:5: error: expected unqualified-id before 'for'
   45 |     for(int i=0;i<n;i++)
      |     ^~~
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:19: error: 'n' was not declared in this scope; did you mean 'yn'?
   45 |     for(int i=0;i<n;i++)
      |                   ^
      |                   yn
Main.cpp:45:17: error: 'i' does not name a type; did you mean 'fi'?
   45 |     for(int i=0;i<n;i++)
      |                 ^
      |                 fi
Main.cpp:45:21: error: 'i' does not name a type; did you mean 'fi'?
   45 |     for(int i=0;i<n;i++)
      |                     ^
      |                     fi
Main.cpp:48:9: error: expected unqualified-id before 'else'
   48 |         else
      |         ^~~~
Main.cpp:50:5: error: 'cout' does not name a type
   50 |     cout<<ans<<endl;
      |     ^~~~
Main.cpp:51:1: error: expected declaration before '}' token
   51 | }
      | ^