# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
196120 | tri | Garage (IOI09_garage) | C++14 | 5 ms | 504 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
#define pb push_back
#define f first
#define s second
int rate[200];
int filled[200];
int weight[3000];
int loc[3000];
int main() {
int N, M;
cin >> N >> M;
for (int i = 0; i < N; i++) {
cin >> rate[i];
}
for (int i = 0; i < M; i++) {
cin >> weight[i];
}
memset(filled, 0, sizeof(filled));
queue<int> q;
ll tCost = 0;
for (int i = 0; i < 2 * M; i++) {
int x;
cin >> x;
if (x > 0) {
x--;
bool fSpace = false;
for (int j = 0; j < N; j++) {
if (!filled[j]) {
filled[j] = true;
loc[x] = j;
fSpace = true;
break;
}
}
if (!fSpace) {
q.push(x);
}
} else {
x = -x;
x--;
int cLoc = loc[x];
filled[cLoc] = false;
tCost += (ll) rate[cLoc] * weight[x];
if (q.size()) {
int nxt = q.front();
q.pop();
filled[cLoc] = true;
loc[nxt] = cLoc;
}
}
}
cout << tCost << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |