# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
650748 | Spade1 | Garage (IOI09_garage) | C++14 | 2 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define ll long long
#define ld long double
#define st first
#define nd second
#define pb push_back
#define INF INT_MAX
using namespace std;
const int N = 110, M = 2020;
int r[N], w[M];
int space[N];
queue<int> q;
void solve() {
int n, m; cin >> n >> m;
for (int i = 1; i <= n; ++i) cin >> r[i];
for (int i = 1; i <= m; ++i) cin >> w[i];
int ans = 0;
for (int i = 1; i <= 2*m; ++i) {
int j; cin >> j;
if (j > 0) {
q.push(j);
for (int i = 1; i <= n; ++i) {
if (space[i] == 0) {
space[i] = q.front();
ans += (r[i]*w[q.front()]);
q.pop();
break;
}
}
}
else {
for (int i = 1; i <= n; ++i) {
if (space[i] == -j) {
space[i] = 0;
if (!q.empty()) {
space[i] = q.front();
ans += (r[i]*w[q.front()]);
q.pop();
}
}
}
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(NULL);
int t = 1;
// cin >> t;
while (t--) {
solve();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |