| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 289693 | b00n0rp | Garage (IOI09_garage) | C++17 | 1 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
#define pb push_back
#define INF 100000000
#define mp make_pair
ll n,m,ans = 0,x;
ll r[101];
ll w[2001];
ll pos[2001];
ll status[101];
int main() {
ios::sync_with_stdio(false);
cin >> n >> m;
fill(pos,pos+m+1,0);
fill(status,status+n+1,0);
for (int i = 1; i <= n; i++) cin >> r[i];
for (int i = 1; i <= m; i++) cin >> w[i];
queue<int> q;
for (int lol = 0; lol < 2*m; lol++){
cin >> x;
if (x > 0){
if (!q.empty()) q.push(x);
else{
bool f = true;
for (int i = 1; i <= n; i++){
if (!status[i]){
f = false;
status[i] = x;
pos[x] = i;
ans += w[x]*r[i];
break;
}
}
if (f) q.push(x);
}
}
else{
x = -x;
status[pos[x]] = 0;
if (!q.empty()){
int next = q.front();
q.pop();
status[pos[x]] = next;
pos[next] = pos[x];
ans += w[next]*r[pos[next]];
}
pos[x] = 0;
}
}
cout << ans << endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
