#include #include #include #include #include using namespace std; void best(int n, int s){ if (n==1){ cout<2){ if (n%2==1){ int med=s+(n-n%2)/2; cout< &B){ if (B[n]==c){ best(n,s); } else { c-=(n-1); int a=n-1; int b=0; while (B[a]+B[b]>c){ a--; b++; } int sa=s; int sb=s+a+1; //cout<<"Dividing "<>q; vector B(100000+1); B[0]=0; B[1]=0; for (int h=2; h<100000+1; h++){ int lowh=((h-1)-(h-1)%2)/2; int highh=((h-1)+(h-1)%2)/2; B[h]=h-1+B[lowh]+B[highh]; } for (int h=0; h>len>>c; long long worst=len*(len-1)/2; int best=B[len]; if (c>worst || c