# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
372898 | apostoldaniel854 | Garage (IOI09_garage) | C++14 | 2 ms | 492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100, MAX_M = 1000;
using ll = long long;
bool taken[1 + MAX_N];
bool wasted[1 + MAX_M];
int parked_at[1 + MAX_M];
int main () {
ios::sync_with_stdio (false);
cin.tie (0); cout.tie (0);
int n, m;
cin >> n >> m;
vector <int> r (n + 1), w (m + 1);
for (int i = 1; i <= n; i++)
cin >> r[i];
for (int i = 1; i <= m; i++)
cin >> w[i];
queue <int> car_line;
ll ans = 0;
for (int i = 1; i <= 2 * m; i++) {
int t;
cin >> t;
if (t > 0)
car_line.push (t);
else {
t = -t;
wasted[t] = true;
if (parked_at[t])
taken[parked_at[t]] = false;
}
while (car_line.size () && wasted[car_line.front ()])
car_line.pop ();
if (car_line.size ()) {
int space = 1;
while (taken[space])
space++;
if (space <= n) {
taken[space] = true;
parked_at[car_line.front ()] = space;
ans += w[car_line.front ()] * r[space];
car_line.pop ();
}
}
}
cout << ans << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |