# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
114321 | MetB | Garage (IOI09_garage) | C++14 | 3 ms | 512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <cstdlib>
#include <string>
#include <set>
#include <stdio.h>
#include <map>
#include <algorithm>
#include <bitset>
#include <queue>
#include <math.h>
#include <stack>
#include <vector>
#include <string.h>
typedef long long ll;
const ll MOD = 1e9 + 7, INF = 1e18;
using namespace std;
ll n, k, a[1000000], m, off[1000000];
vector <ll> v;
ll u[100], s[100], w[5000], p[5000], ans;
queue <ll> waiting;
int main ()
{
cin >> n >> m;
for (ll i = 0; i < n; i++)
scanf ("%lld", &s[i]);
for (ll i = 0; i < m; i++)
scanf ("%lld", &w[i]);
for (ll i = 0; i < 2 * m; i++)
{
ll t;
scanf ("%lld", &t);
if (t >= 0)
{
t--;
bool b = false;
for (ll j = 0; j < n; j++)
{
if (!u[j])
{
p[t] = j;
ans += s[j] * w[t];
u[j] = 1;
b = true;
break;
}
}
if (!b) waiting.push (t);
}
else
{
t = abs (t) - 1;
off[t] = 1;
u[p[t]] = 0;
while (!waiting.empty () && off[waiting.front ()]) waiting.pop ();
if (!waiting.empty ())
{
u[p[t]] = 1;
p[waiting.front ()] = p[t];
ans += s[p[t]] * w[waiting.front ()];
waiting.pop ();
}
}
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |