Submission #31143

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
311432017-08-11 12:09:09cscandkswonLast supper (IOI12_supper)C++14
100 / 100
333 ms145544 KiB
#include "advisor.h"
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
const int MAXN=100005;
deque<int> D[MAXN];
multimap<int, int> S;
unordered_set<int> U;
int A[MAXN];
void ComputeAdvice(int *C, int N, int K, int M) {
int i;
for(i=0; i<N; i++) D[C[i]].push_back(i);
for(i=0; i<N; i++) D[i].push_back(N);
for(i=0; i<K; i++) S.insert(make_pair(D[i].front(), i));
for(i=0; i<K; i++) U.insert(i);
for(i=0; i<N; i++){
if(U.find(C[i])!=U.end()){
A[i]=-1;
S.erase(S.begin());
D[C[i]].pop_front();
S.insert(make_pair(D[C[i]].front(), C[i]));
}
else{
pair<int, int> p=*(--S.end());
S.erase(--S.end());
A[i]=p.second;
D[C[i]].pop_front();
S.insert(make_pair(D[C[i]].front(), C[i]));
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...