10720 | 2024-04-10 16:26:40 | peti1234 | A válaszadás nehézségei | cpp17 | Wrong answer 0/100 | 8ms | 4380 KiB |
#include <bits/stdc++.h>
#include "AdamEsEva.h"
using namespace std;
const long long maxval=1e18, cel=67, speckerd=4; // hogy ne csorduljon tul
int kerddb;
long long kezd[cel+1], veg[cel+1];
void process(long long a) {
if (a>maxval) {
a=1;
}
bool res=ask(a);
for (int i=1; i<=cel; i++) {
if (i>=kerddb) {
if (res) kezd[i]=max(kezd[i], a);
else veg[i]=min(veg[i], a-1);
} else {
if (res) veg[i]=min(veg[i], a-1);
else kezd[i]=max(kezd[i], a);
}
}
}
long long calc(long long a) {
long long sum=0;
for (int i=1; i<=kerddb; i++) {
long long s=veg[i]-max(kezd[i], a);
if (s>=0) sum+=s+1;
}
for (int i=kerddb+1; i<=cel; i++) {
long long s=min(veg[i], a-1)-kezd[i];
if (s>=0) sum+=s+1;
}
return sum;
}
void new_game() {
kerddb=0;
for (int i=1; i<=cel; i++) {
kezd[i]=1, veg[i]=maxval;
}
for (int i=1; i<=speckerd; i++) {
process((kezd[cel]+veg[cel])/2);
}
for (int j=speckerd+1; j<=cel; j++) {
long long sum=0;
for (int i=1; i<=cel; i++) {
if (kezd[i]<=veg[i]) {
sum+=veg[i]-kezd[i]+1;
}
}
long long fel=sum/2;
long long lo=1, hi=maxval+1, mid, vallo=calc(lo), valhi=calc(hi), valmid;
while (hi-lo>1) {
mid=(hi+lo+1)/2;
valmid=calc(mid);
if ((valmid<=fel && vallo<=fel) || (valmid>fel && vallo>fel)) {
lo=mid;
vallo=valmid;
} else {
hi=mid;
valhi=valmid;
}
}
if (abs(valhi-fel)<abs(vallo-fel)) process(hi);
else process(lo);
}
long long sum=0, res=0;
for (int j=1; j<=cel; j++) {
if (kezd[j]<=veg[j]) {
res=kezd[j];
sum+=veg[j]-kezd[j]+1;
}
}
answer(res);
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/100 | ||||||
1 | Wrong answer | 4ms | 1884 KiB | ||||
2 | Wrong answer | 4ms | 2120 KiB | ||||
3 | Wrong answer | 4ms | 2284 KiB | ||||
4 | Wrong answer | 4ms | 2496 KiB | ||||
5 | Wrong answer | 4ms | 2744 KiB | ||||
6 | Wrong answer | 4ms | 2916 KiB | ||||
7 | Wrong answer | 4ms | 3168 KiB | ||||
8 | Wrong answer | 4ms | 3384 KiB | ||||
9 | Wrong answer | 4ms | 3552 KiB | ||||
10 | Wrong answer | 4ms | 3796 KiB | ||||
11 | Wrong answer | 4ms | 4008 KiB | ||||
12 | Wrong answer | 4ms | 4060 KiB | ||||
13 | Wrong answer | 4ms | 4064 KiB | ||||
14 | Wrong answer | 4ms | 4064 KiB | ||||
15 | Wrong answer | 4ms | 4060 KiB | ||||
16 | Wrong answer | 4ms | 4096 KiB | ||||
17 | Wrong answer | 4ms | 4212 KiB | ||||
18 | Wrong answer | 4ms | 4136 KiB | ||||
19 | Wrong answer | 4ms | 4140 KiB | ||||
20 | Wrong answer | 4ms | 4132 KiB | ||||
21 | Wrong answer | 4ms | 4280 KiB | ||||
22 | Wrong answer | 4ms | 4380 KiB | ||||
23 | Wrong answer | 4ms | 4232 KiB | ||||
24 | Wrong answer | 4ms | 4232 KiB | ||||
25 | Wrong answer | 4ms | 4236 KiB | ||||
26 | Wrong answer | 4ms | 4240 KiB | ||||
27 | Wrong answer | 4ms | 4240 KiB | ||||
28 | Wrong answer | 4ms | 4236 KiB | ||||
29 | Wrong answer | 4ms | 4236 KiB | ||||
30 | Wrong answer | 4ms | 4236 KiB | ||||
31 | Wrong answer | 4ms | 4348 KiB | ||||
32 | Wrong answer | 4ms | 4232 KiB | ||||
33 | Wrong answer | 4ms | 4236 KiB | ||||
34 | Wrong answer | 4ms | 4236 KiB | ||||
35 | Wrong answer | 8ms | 4236 KiB | ||||
36 | Wrong answer | 4ms | 4364 KiB |