#include "advisor.h"
#include <bits/stdc++.h>
using namespace std;
const int N_BITS = 13;
void ComputeAdvice(int *C, int N, int K, int M) {
for (int iVal = 0; iVal < N; ++iVal){
int val = C[iVal];
for (int i = 0; i < N_BITS; ++i)
WriteAdvice((val&(1 << i)) > 0);
}
}
#include "assistant.h"
#include <bits/stdc++.h>
using namespace std;
const int N_BITS = 13;
void Assist(unsigned char *A, int N, int K, int R) {
vector<int> C;
for (int i = 0; i < R; i += N_BITS){
int tot = 0;
for (int bit = 0; bit < N_BITS; ++bit)
tot += A[i + bit] * (1 << bit);
C.push_back(tot);
}
queue<int> file[N];
for (int ind = 0; ind < N; ++ind)
file[C[ind]].push(ind);
bool presents[N];
for (int i = 0; i < N; ++i)
presents[i] = false;
for (int i = 0; i < K; ++i)
presents[i] = true;
for (int iReq = 0; iReq < N; ++iReq){
int proc = GetRequest();
if (!presents[proc]){
int procUtil = -1, color = -1;
for (int in = 0; in < N; ++in){
if (!presents[in]) continue;
while (!file[in].empty() && file[in].front() < iReq)
file[in].pop();
if (file[in].empty()){
procUtil = 1e9;
color = in;
}
else if (file[in].front() > procUtil){
procUtil = file[in].front();
color = in;
}
}
PutBack(color);
presents[color] = false;
presents[proc] = true;
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
484 KB |
Output is correct |
2 |
Correct |
2 ms |
612 KB |
Output is correct |
3 |
Correct |
5 ms |
1408 KB |
Output is correct |
4 |
Correct |
20 ms |
2752 KB |
Output is correct |
5 |
Correct |
49 ms |
4288 KB |
Output is correct |
6 |
Correct |
50 ms |
4336 KB |
Output is correct |
7 |
Correct |
28 ms |
4428 KB |
Output is correct |
8 |
Correct |
46 ms |
4312 KB |
Output is correct |
9 |
Correct |
65 ms |
4288 KB |
Output is correct |
10 |
Correct |
49 ms |
4348 KB |
Output is correct |
11 |
Correct |
53 ms |
4340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
199 ms |
8344 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2529 ms |
62908 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
484 KB |
Error - advice is too long |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2529 ms |
78196 KB |
Time limit exceeded |
2 |
Execution timed out |
2586 ms |
78020 KB |
Time limit exceeded |
3 |
Execution timed out |
2596 ms |
78108 KB |
Time limit exceeded |
4 |
Execution timed out |
2508 ms |
78116 KB |
Time limit exceeded |
5 |
Execution timed out |
2550 ms |
78192 KB |
Time limit exceeded |
6 |
Execution timed out |
2544 ms |
78028 KB |
Time limit exceeded |
7 |
Execution timed out |
2549 ms |
77980 KB |
Time limit exceeded |
8 |
Execution timed out |
2542 ms |
78120 KB |
Time limit exceeded |
9 |
Execution timed out |
2520 ms |
78276 KB |
Time limit exceeded |
10 |
Execution timed out |
2536 ms |
78152 KB |
Time limit exceeded |