Submission #1080808

#TimeUsernameProblemLanguageResultExecution timeMemory
1080808Dennis_JasonGarage (IOI09_garage)C++14
100 / 100
8 ms520 KiB
#include <bits/stdc++.h> #define NMAX 100001 #define pb push_back #define eb emplace_back #define MOD 100003 #define nl '\n' #define INF 2147483647 #define LLONG_MAX 9223372036854775807 #define pii pair<int,int> #define tpl tuple<int,int,int> //#pragma GCC optimize("O3") using namespace std; ifstream fin("cerc.in"); ofstream fout("cerc.out"); /* * * ================DEMONSTRATION=================== =====================END======================== */ int n,m,ans; set<tpl>space; vector<int>w; vector<int>arrived; vector<int>depart; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>m; w.resize(m+1); arrived.resize(m+1); depart.resize(m+1); for(int i=1;i<=n;++i) { int x; cin>>x; space.insert({-1,i,x}); } for(int i=1;i<=m;++i) { cin>>w[i]; } queue<int>q; for(int i=1;i<=2*m;++i) { int x; cin>>x; if(x>0) { q.push(x); arrived[x]=i; } else { depart[abs(x)]=i; } } while(!q.empty()) { auto car=q.front(); q.pop(); vector<std::set<tuple<int, int, int>>::iterator> aux; for(auto it=space.begin();it!=space.end();++it) { auto [timp,loc,pret]=*it; if(timp<=arrived[car]) aux.pb(it); } for(auto x:aux) { auto [timp,loc,pret]=*x; space.erase(x); space.insert({-1,loc,pret}); } auto it=space.begin(); auto[timp,loc,pret]=*it; ans+=(w[car]*pret); space.erase(it); space.insert({depart[car],loc,pret}); // cout<<car<<" "<<loc<<nl; } cout<<ans; return 0; }

Compilation message (stderr)

garage.cpp:8: warning: "LLONG_MAX" redefined
    8 | #define LLONG_MAX 9223372036854775807
      | 
In file included from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:195,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-linux-gnu/10/include/limits.h:34,
                 from /usr/include/c++/10/climits:42,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:39,
                 from garage.cpp:1:
/usr/include/limits.h:135: note: this is the location of the previous definition
  135 | #  define LLONG_MAX __LONG_LONG_MAX__
      | 
garage.cpp: In function 'int main()':
garage.cpp:69:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   69 |             auto [timp,loc,pret]=*it;
      |                  ^
garage.cpp:75:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   75 |             auto [timp,loc,pret]=*x;
      |                  ^
garage.cpp:81:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   81 |         auto[timp,loc,pret]=*it;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...