| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 124627 | arthurconmy | Garage (IOI09_garage) | C++14 | 5 ms | 400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// check ctrl+v :^)
/* Arthur Conmy IOI template - minimal! */
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <queue>
#include <bitset>
#include <random>
#include <stack>
#include <deque>
#include <chrono>
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;
#define REP(i,a,b) \
for(int i = int(a); i<=int(b); i++)
int main()
{
#ifdef ARTHUR_LOCAL
ifstream cin("input.txt");
#endif
int n,m;
cin>>n>>m;
vi rate = {-1};
REP(i,1,n)
{
int r;
cin>>r;
rate.push_back(r);
}
vi weight={-1};
REP(i,1,m)
{
int w;
cin>>w;
weight.push_back(w);
}
priority_queue<int,vector<int>,greater<int>> avail;
queue<int> wait;
REP(i,1,n) avail.push(i);
int ans=0;
vi in_gar(max(n,m)+1);
REP(i,1,2*m)
{
int cur;
cin>>cur;
if(cur<0)
{
avail.push(in_gar[-cur]);
if(!wait.empty())
{
ans+=rate[avail.top()]*weight[wait.front()];
in_gar[wait.front()]=avail.top();
wait.pop();
avail.pop();
}
}
else
{
if(avail.empty()) wait.push(cur);
else
{
ans+=rate[avail.top()]*weight[cur];
in_gar[cur]=avail.top();
avail.pop();
}
}
}
cout << ans << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
