#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
const int N = 110;
int b[N], r[N], mark[N];
int minValue(int n, int w) {
for(int i = 0; i < n; i++) b[i] = 0;
b[0] = 1;
playRound(b, r);
for(int i = 0; i < n; i++) if (!r[i]) return i;
return 0;
}
int maxValue(int n, int w) {
for(int i = 0; i < n; i++) mark[i] = 1;
while (1) {
int cnt = 0;
for(int i = 0; i < n; i++) cnt += mark[i];
if (cnt == 1) break;
int val = w / cnt;
for(int i = 0; i < n; i++) {
if (mark[i]) b[i] = val;
else b[i] = 0;
}
playRound(b, r);
for(int i = 0; i < n; i++) mark[i] &= (r[i] > 0);
}
for(int i = 0; i < n; i++) if (mark[i]) return i;
return 0;
}
int greaterValue(int n, int w) {
int L = 1, R = min(w / 2, 8);
int res = 2;
while (L <= R) {
int mid = L + R >> 1;
for(int i = 2; i < n; i++) b[i] = 0;
b[0] = b[1] = mid;
playRound(b, r);
int tmp = 0;
for(int i = 0; i < 2; i++) if (r[i] > b[i]) tmp++;
if (tmp == 2) L = mid + 1;
else {
if (tmp == 1) {
if (r[0] > b[0]) res = 0;
else res = 1;
}
R = mid - 1;
}
}
return res;
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
// TODO: Implement Subtask 4 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
} else {
// TODO: Implement Subtask 5 solution here.
// You may leave this block unmodified if you are not attempting this
// subtask.
}
}
Compilation message
koala.cpp: In function 'int greaterValue(int, int)':
koala.cpp:36:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
36 | int mid = L + R >> 1;
| ~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
4 ms |
208 KB |
Output is correct |
4 |
Correct |
5 ms |
336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
208 KB |
Output is correct |
2 |
Correct |
13 ms |
208 KB |
Output is correct |
3 |
Correct |
18 ms |
208 KB |
Output is correct |
4 |
Correct |
12 ms |
324 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Partially correct |
101 ms |
328 KB |
Output is partially correct |
2 |
Partially correct |
95 ms |
324 KB |
Output is partially correct |
3 |
Partially correct |
108 ms |
316 KB |
Output is partially correct |
4 |
Partially correct |
113 ms |
324 KB |
Output is partially correct |
5 |
Partially correct |
106 ms |
436 KB |
Output is partially correct |
6 |
Partially correct |
107 ms |
452 KB |
Output is partially correct |
7 |
Partially correct |
105 ms |
324 KB |
Output is partially correct |
8 |
Partially correct |
106 ms |
328 KB |
Output is partially correct |
9 |
Partially correct |
106 ms |
336 KB |
Output is partially correct |
10 |
Partially correct |
106 ms |
448 KB |
Output is partially correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
208 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |