#include "advisor.h"
int cntt[100100];
void ComputeAdvice(int *C, int N, int K, int M) {
for (int i=0;i<N;i++) {
cntt[C[i]]++;
}
for (int i=0;i<N;i++) {
for (int j=0;j<cntt[i];j++) {
WriteAdvice(0);
}
WriteAdvice(1);
}
}
#include "assistant.h"
#include <vector>
#include <set>
using namespace std;
int cnt[100100];
bool removable[100100];
set<int> rminscf;
set<int> inscf;
void Assist(unsigned char *A, int N, int K, int R) {
int cur=0;
for (int i=0;i<R;i++) {
if (A[i]==0) cnt[cur]++;
else cur++;
}
for (int i=0;i<N;i++) {
if (cnt[i]==0) removable[i]=true;
}
for (int i=0;i<K;i++) {
if (removable[i]) rminscf.insert(i);
else inscf.insert(i);
}
int req;
for (int i=0;i<N;i++) {
req=GetRequest();
if (inscf.find(req)==inscf.end()&&rminscf.find(req)==rminscf.end()) {
//req is not in scf
if (!rminscf.empty()) {
PutBack(*rminscf.begin());
rminscf.erase(rminscf.begin());
} else {
PutBack(*inscf.begin());
inscf.erase(inscf.begin());
}
inscf.insert(req);
}
cnt[req]--;
if (cnt[req]==0) {
removable[req]=true;
inscf.erase(req);
rminscf.insert(req);
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
612 KB |
Output is correct |
2 |
Correct |
4 ms |
892 KB |
Output is correct |
3 |
Correct |
5 ms |
980 KB |
Output is correct |
4 |
Incorrect |
7 ms |
1424 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
20 ms |
1772 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
166 ms |
6516 KB |
Output is correct |
2 |
Correct |
221 ms |
9028 KB |
Output is correct |
3 |
Correct |
203 ms |
10272 KB |
Output is correct |
4 |
Correct |
210 ms |
10336 KB |
Output is correct |
5 |
Incorrect |
193 ms |
10400 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
10400 KB |
Output is correct |
2 |
Correct |
14 ms |
10400 KB |
Output is correct |
3 |
Incorrect |
11 ms |
10400 KB |
Output isn't correct - not an optimal way |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
199 ms |
10804 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
216 ms |
11784 KB |
Output is correct - 200000 bits used |
3 |
Correct |
188 ms |
13068 KB |
Output is correct - 200000 bits used |
4 |
Correct |
172 ms |
14484 KB |
Output is correct - 200000 bits used |
5 |
Correct |
168 ms |
15660 KB |
Output is correct - 200000 bits used |
6 |
Correct |
176 ms |
16708 KB |
Output is correct - 200000 bits used |
7 |
Correct |
182 ms |
17768 KB |
Output is correct - 199678 bits used |
8 |
Correct |
175 ms |
19020 KB |
Output is correct - 200000 bits used |
9 |
Correct |
197 ms |
20368 KB |
Output is correct - 200000 bits used |
10 |
Incorrect |
169 ms |
21384 KB |
Output isn't correct - not an optimal way |