| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1096953 | vjudge1 | Garage (IOI09_garage) | C++17 | 1 ms | 452 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define debug(...)
#endif
#define SZ(x) ((int) x.size())
#define int long long
#define vvi vector<vector<int>>
#define endl '\n'
#define pii pair<int, int>
#define all(v) (v).begin(), (v).end()
template <typename T>
istream &operator>>(istream& is, vector<T> &v) {
for (auto &x: v) is >> x;
return is;
}
void run_test() {
int n, m;
cin >> n >> m;
vector<int> rate(n+1), wt(m+1);
for (int i = 1; i <= n; i++) cin >> rate[i];
for (int i = 1; i <= m; i++) cin >> wt[i];
vector<int> ad(2*m);
cin >> ad;
vector<int> garage(n+1, -1);
queue<int> q;
int ans = 0;
for (int i = 0; i < 2*m; i++) {
int car = ad[i];
if (car < 0) {
for (int j = 1; j <= n; j++) {
if (garage[j] == -car) {
garage[j] = -1;
break;
}
}
}
if (car > 0) q.push(car);
if (q.empty()) continue;
int top = q.front();
bool parked = false;
for (int j = 1; j <= n; j++) {
if (garage[j] == -1) {
parked = true;
garage[j] = top;
ans += wt[top] * rate[j];
break;
}
}
if (parked) q.pop();
}
cout << ans << endl;
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tc = 1;
// cin >> tc;
while (tc--) {
run_test();
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
