# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1080808 | Dennis_Jason | Garage (IOI09_garage) | C++14 | 8 ms | 520 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |