#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define int ll
#include "koala.h"
int B[100],R[100];
int minValue(int N, int W){
B[0] = 1;
for(int i=1;i<=99;i++){
B[i] = 0;
}
playRound(B,R);
for(int i=0;i<=99;i++){
if(R[i]==0){
return i;
}
}
return 0;
}
int maxValue(int N, int W){
vector<int> curr;
for(int i=0;i<=99;i++){
curr.push_back(i);
}
while(curr.size()>1){
for(int i=0;i<=99;i++){
B[i] = 0;
}
int cnt = 100/curr.size();
for(int i:curr){
B[i] = cnt;
}
playRound(B,R);
vector<int> curr2;
for(int i:curr){
if(R[i]>B[i]){
curr2.push_back(i);
}
}
curr = curr2;
}
return curr[0];
}
int greaterValue(int N, int W){
int low=0,high=6;
vector<int> v = {1,2,3,4,5,6,8};
while(1){
int mid = (low+high)/2;
for(int i=0;i<=99;i++){
B[i] = 0;
}
B[0] = v[mid];
B[1] = v[mid];
playRound(B,R);
if(R[0]>B[0] and R[1]>B[1]){
low = mid+1;
}
else if(R[0]<=B[0] and R[1]<=B[1]){
high = mid-1;
}
else if(R[0]>B[0]){
return 0;
}
else{
return 1;
}
}
return 0;
}
int n,w;
int arr[100];
void dosplit(vector<int> x, int l, int r){
if(x.size()==1){
arr[x[0]] = l;
return;
}
int low=1,high=w/(r-l+1);
while(1){
int mid=(low+high)/2;
for(int i=0;i<=n-1;i++){
B[i] = 0;
}
for(int i:x){
B[i] = mid;
}
playRound(B,R);
vector<int> x1,x2;
for(int i:x){
if(R[i]>B[i]){
x2.push_back(i);
}
else{
x1.push_back(i);
}
}
if(x1.size()>0 and x2.size()>0){
dosplit(x1,l,l+x1.size()-1);
dosplit(x2,r-x2.size()+1,r);
break;
}
else if(x1.size()>0){
high = mid-1;
}
else{
low = mid+1;
}
}
}
void allValues(int N, int W, int *P){
n = N;
w = W;
if(W==2*N){
vector<int> v;
for(int i=0;i<N;i++){
v.push_back(i);
}
dosplit(v,0,N-1);
for(int i=0;i<N;i++){
P[i] = arr[i];
}
}
else{
vector<int> v;
for(int i=0;i<N;i++){
v.push_back(i);
}
dosplit(v,0,N-1);
for(int i=0;i<N;i++){
P[i] = arr[i];
}
}
}
# |
결과 |
실행 시간 |
메모리 |
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 |
7 ms |
208 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
13 ms |
208 KB |
Output is correct |
2 |
Correct |
13 ms |
208 KB |
Output is correct |
3 |
Correct |
16 ms |
208 KB |
Output is correct |
4 |
Correct |
12 ms |
324 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
316 KB |
Output is correct |
2 |
Correct |
81 ms |
324 KB |
Output is correct |
3 |
Correct |
63 ms |
332 KB |
Output is correct |
4 |
Correct |
62 ms |
324 KB |
Output is correct |
5 |
Correct |
69 ms |
332 KB |
Output is correct |
6 |
Correct |
64 ms |
336 KB |
Output is correct |
7 |
Correct |
66 ms |
320 KB |
Output is correct |
8 |
Correct |
63 ms |
320 KB |
Output is correct |
9 |
Correct |
67 ms |
332 KB |
Output is correct |
10 |
Correct |
69 ms |
320 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
12 ms |
320 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |