#include "koala.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int minValue(int N, int W) {
int P[N], T[N];
rep(i, N) P[i]=0;
P[0]=1;
playRound(P, T);
rep(i, N) if(P[i]>=T[i]) return i;
return 0;
}
int maxValue(int N, int W) {
int P[N], T[N];
vector<int>V(N);
rep(i, N) V[i]=0;
int ans=-1;
while(true) {
int ile=N;
rep(i, N) if(V[i]) --ile;
if(ile==1) {
rep(i, N) if(!V[i]) ans=i;
break;
}
rep(i, N) if(V[i]) P[i]=0; else P[i]=W/ile;
playRound(P, T);
rep(i, N) if(P[i]>=T[i]) V[i]=1;
int ans=0;
rep(i, N) if(!V[i]) ++ans;
}
return ans;
}
int greaterValue(int N, int W) {
int P[N], T[N], po=2, ko=8;
rep(i, N) P[i]=0;
while(po<ko) {
int sr=(po+ko)/2;
P[0]=P[1]=sr;
playRound(P, T);
if(T[0]>sr && T[1]<=sr) return 0;
if(T[0]<=sr && T[1]>sr) return 1;
if(T[0]>sr) po=sr+1; else ko=sr-1;
}
if(po==2) po=1;
P[0]=P[1]=po;
playRound(P, T);
if(T[0]<=po) return 1;
return 0;
}
bool comp(int a, int b) {
int P[100], T[100];
rep(i, 100) P[i]=0;
P[a]=P[b]=100;
playRound(P, T);
if(T[a]<=P[a]) return true;
return false;
}
vector<int>znajdz50() {
vector<int>ans, czy(100);
rep(j, 50) {
int P[100], T[100];
rep(i, 100) P[i]=czy[i];
int k=j+1;
rep(i, 100) if(!czy[i] && k) {
P[i]=1;
--k;
}
playRound(P, T);
rep(i, 100) if(!czy[i] && P[i]>=T[i]) {
czy[i]=1;
ans.pb(i);
}
}
return ans;
}
vector<int>solve(vector<int>V) {
if(V.size()==1) return V;
int N=100;
int P[N], T[N], k=min(N/(int)V.size(), 8);
rep(i, N) P[i]=0;
for(auto i : V) P[i]=k;
playRound(P, T);
vector<int>A, B;
for(auto i : V) if(P[i]>=T[i]) A.pb(i); else B.pb(i);
A=solve(A);
B=solve(B);
for(auto i : B) A.pb(i);
return A;
}
void allValues(int N, int W, int *P) {
if (W == 2*N) {
int T[N];
rep(i, N) T[i]=i;
stable_sort(T, T+N, comp);
rep(i, N) P[T[i]]=i+1;
return;
}
vector<int>V=znajdz50(), Q, odw(100);
for(auto i : V) odw[i]=1;
rep(i, 100) if(!odw[i]) Q.pb(i);
Q=solve(Q);
rep(i, 50) {
P[V[i]]=i+1;
P[Q[i]]=i+51;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
3 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
344 KB |
Output is correct |
2 |
Correct |
10 ms |
344 KB |
Output is correct |
3 |
Correct |
10 ms |
452 KB |
Output is correct |
4 |
Correct |
10 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
41 ms |
488 KB |
Output is correct |
2 |
Correct |
48 ms |
468 KB |
Output is correct |
3 |
Correct |
40 ms |
488 KB |
Output is correct |
4 |
Correct |
39 ms |
480 KB |
Output is correct |
5 |
Correct |
41 ms |
476 KB |
Output is correct |
6 |
Correct |
41 ms |
484 KB |
Output is correct |
7 |
Correct |
40 ms |
472 KB |
Output is correct |
8 |
Correct |
41 ms |
460 KB |
Output is correct |
9 |
Correct |
40 ms |
464 KB |
Output is correct |
10 |
Correct |
40 ms |
464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
600 KB |
Output is correct |
2 |
Correct |
28 ms |
344 KB |
Output is correct |
3 |
Correct |
28 ms |
344 KB |
Output is correct |
4 |
Correct |
27 ms |
344 KB |
Output is correct |
5 |
Correct |
27 ms |
344 KB |
Output is correct |
6 |
Correct |
27 ms |
344 KB |
Output is correct |
7 |
Correct |
27 ms |
344 KB |
Output is correct |
8 |
Correct |
30 ms |
344 KB |
Output is correct |
9 |
Correct |
31 ms |
452 KB |
Output is correct |
10 |
Correct |
29 ms |
700 KB |
Output is correct |
11 |
Correct |
28 ms |
344 KB |
Output is correct |
12 |
Correct |
12 ms |
344 KB |
Output is correct |
13 |
Correct |
26 ms |
344 KB |
Output is correct |
14 |
Correct |
24 ms |
448 KB |
Output is correct |
15 |
Correct |
24 ms |
344 KB |
Output is correct |
16 |
Correct |
25 ms |
452 KB |
Output is correct |
17 |
Correct |
27 ms |
344 KB |
Output is correct |
18 |
Correct |
24 ms |
344 KB |
Output is correct |
19 |
Correct |
25 ms |
344 KB |
Output is correct |
20 |
Correct |
27 ms |
448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
384 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
3 ms |
344 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
344 KB |
Output is correct |
10 |
Correct |
3 ms |
596 KB |
Output is correct |
11 |
Correct |
3 ms |
344 KB |
Output is correct |
12 |
Correct |
3 ms |
452 KB |
Output is correct |
13 |
Correct |
3 ms |
344 KB |
Output is correct |
14 |
Correct |
3 ms |
344 KB |
Output is correct |
15 |
Correct |
3 ms |
344 KB |
Output is correct |
16 |
Correct |
3 ms |
344 KB |
Output is correct |
17 |
Correct |
3 ms |
344 KB |
Output is correct |
18 |
Correct |
3 ms |
344 KB |
Output is correct |
19 |
Correct |
2 ms |
344 KB |
Output is correct |
20 |
Correct |
3 ms |
344 KB |
Output is correct |
21 |
Correct |
3 ms |
344 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
2 ms |
344 KB |
Output is correct |
24 |
Correct |
3 ms |
344 KB |
Output is correct |
25 |
Correct |
2 ms |
344 KB |
Output is correct |
26 |
Correct |
3 ms |
344 KB |
Output is correct |
27 |
Correct |
3 ms |
448 KB |
Output is correct |
28 |
Correct |
3 ms |
344 KB |
Output is correct |
29 |
Correct |
2 ms |
344 KB |
Output is correct |
30 |
Correct |
3 ms |
344 KB |
Output is correct |
31 |
Correct |
2 ms |
344 KB |
Output is correct |
32 |
Correct |
3 ms |
344 KB |
Output is correct |
33 |
Correct |
3 ms |
344 KB |
Output is correct |
34 |
Correct |
3 ms |
344 KB |
Output is correct |
35 |
Correct |
2 ms |
344 KB |
Output is correct |
36 |
Correct |
3 ms |
344 KB |
Output is correct |
37 |
Correct |
3 ms |
464 KB |
Output is correct |
38 |
Correct |
3 ms |
344 KB |
Output is correct |
39 |
Correct |
2 ms |
344 KB |
Output is correct |
40 |
Correct |
2 ms |
344 KB |
Output is correct |