| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 732791 | Roman70 | Garage (IOI09_garage) | C++17 | 2 ms | 340 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define forn(i,n) for(int i = 0;i<n;i++)
#define ll long long
#define pb push_back
#define sz(a) a.size()
using namespace std;
struct cmp{
bool operator()(const int a, const int b){
return a > b;
}
};
void solve()
{
int n,m;
cin >> n >> m;
int rate[n];
int w[m];
priority_queue<int,vector<int>,cmp>loturi;
int park[m];
forn(i,n){
int cost;
cin >> cost;
loturi.push(cost);
}
forn(i,m){
cin >> w[i];
}
queue<int>c;
int p = 0;
forn(i,2*m){
int car;
cin >> car;
if(car > 0){
if(loturi.size()){
int pret = loturi.top();
p += (pret * w[car-1]);
loturi.pop();
park[car-1] = pret;
}
else c.push(car-1);
}
else{
car*=(-1);
if(c.size()){
int cr = c.front();
c.pop();
p += (park[car-1] * w[cr]);
park[cr] = park[car-1];
}
else loturi.push(park[car-1]);
}
}
cout<<p;
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
// freopen("num.txt","r",stdin);
int t = 1;
// cin >> t;
while(t--) solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
