# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
381835 | thecodingwizard | 최후의 만찬 (IOI12_supper) | C++11 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "assistant.h"
using namespace std;
#define f first
#define s second
void Assist(unsigned char *A, int N, int K, int R) {
map<int, int> useLeft;
int idx = 0;
map<int, int> pos;
map<int, int> revPos;
queue<int> toRemove;
for (int i = 0; i < K; i++) {
int ct = 0;
while (A[idx] != 0) {
ct++;
idx++;
}
idx++;
useLeft[i] = ct;
cout << i << " will be used " << ct << " times " << endl;
if (ct == 0) toRemove.push(i);
pos[i] = i;
revPos[i] = i;
}
for (int i = 0; i < N; i++) {
int req = GetRequest();
if (pos.count(req)) {
useLeft[pos[req]]--;
if (useLeft[pos[req]] == 0) {
toRemove.push(pos[req]);
}
} else {
int remove = toRemove.front(); toRemove.pop();
PutBack(revPos[remove]);
pos.erase(revPos[remove]);
revPos[remove] = req;
pos[req] = remove;
int ct = 0;
if (idx == R) {
ct = 10000000;
} else {
while (A[idx] != 0) {
ct++;
idx++;
}
idx++;
}
useLeft[remove] = ct;
if (ct == 0) {
toRemove.push(remove);
}
}
}
}