# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1080808 | 2024-08-29T14:29:42 Z | Dennis_Jason | Garage (IOI09_garage) | C++14 | 8 ms | 520 KB |
#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
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 344 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 1 ms | 348 KB | Output is correct |
10 | Correct | 1 ms | 348 KB | Output is correct |
11 | Correct | 2 ms | 344 KB | Output is correct |
12 | Correct | 1 ms | 348 KB | Output is correct |
13 | Correct | 2 ms | 348 KB | Output is correct |
14 | Correct | 2 ms | 348 KB | Output is correct |
15 | Correct | 3 ms | 348 KB | Output is correct |
16 | Correct | 6 ms | 348 KB | Output is correct |
17 | Correct | 4 ms | 348 KB | Output is correct |
18 | Correct | 5 ms | 520 KB | Output is correct |
19 | Correct | 2 ms | 344 KB | Output is correct |
20 | Correct | 8 ms | 348 KB | Output is correct |