#include<bits/stdc++.h>
#include "advisor.h"
using namespace std;
void ComputeAdvice(int *C, int N, int K, int M)
{
int frq[100002];
memset(frq, 0, sizeof(frq));
for(int i = 0; i < N; ++i)
frq[C[i]]++;
for(int i = 0; i < N; ++i)
{
for(int j = 1; j <= frq[i]; ++j)
WriteAdvice(0);
WriteAdvice(1);
}
}
#include<bits/stdc++.h>
#include "assistant.h"
using namespace std;
void Assist(unsigned char *A, int N, int K, int R)
{
int frq[100002];
memset(frq, 0, sizeof(frq));
int poz = 0;
for(int i = 0; i < R; ++i)
{
if(A[i] == 1)
++poz;
else
++frq[poz];
}
bool is[100002];
memset(is, 0, sizeof(is));
set<pair<int, int> >frq1;
set<pair<int, int> >frq2;
for(int i = 0; i < K; ++i)
frq1.insert({frq[i], i}), is[i] = 1;
for(int i = 0; i < N; ++i)
{
int color = GetRequest();
if(!is[color])
{
pair<int, int> p = *frq1.begin();
frq1.erase(p);
PutBack(p.second);
is[p.second] = 0;
is[color] = 1;
frq2.insert(p);
frq1.insert({frq[color], color});
frq2.erase({frq[color], color});
}
frq1.erase({frq[color], color});
--frq[color];
frq1.insert({frq[color], color});
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1760 KB |
Output is correct |
2 |
Correct |
6 ms |
1752 KB |
Output is correct |
3 |
Correct |
8 ms |
1796 KB |
Output is correct |
4 |
Incorrect |
9 ms |
1696 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
2432 KB |
Output isn't correct - not an optimal way |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
158 ms |
7788 KB |
Output is correct |
2 |
Correct |
203 ms |
9472 KB |
Output is correct |
3 |
Correct |
211 ms |
9492 KB |
Output is correct |
4 |
Correct |
198 ms |
9340 KB |
Output is correct |
5 |
Incorrect |
176 ms |
8312 KB |
Output isn't correct - not an optimal way |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1956 KB |
Output is correct |
2 |
Correct |
11 ms |
1976 KB |
Output is correct |
3 |
Correct |
12 ms |
1844 KB |
Output is correct |
4 |
Incorrect |
12 ms |
1852 KB |
Output isn't correct - not an optimal way |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
214 ms |
9028 KB |
Output isn't correct - not an optimal way |
2 |
Correct |
205 ms |
9056 KB |
Output is correct - 200000 bits used |
3 |
Correct |
195 ms |
9052 KB |
Output is correct - 200000 bits used |
4 |
Correct |
198 ms |
9364 KB |
Output is correct - 200000 bits used |
5 |
Correct |
196 ms |
9560 KB |
Output is correct - 200000 bits used |
6 |
Correct |
194 ms |
9496 KB |
Output is correct - 200000 bits used |
7 |
Correct |
203 ms |
9376 KB |
Output is correct - 199678 bits used |
8 |
Correct |
197 ms |
9456 KB |
Output is correct - 200000 bits used |
9 |
Correct |
195 ms |
9448 KB |
Output is correct - 200000 bits used |
10 |
Correct |
196 ms |
10876 KB |
Output is correct - 200000 bits used |