1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "cielib.h"

#define MAX_D	510
int D, R;
int E[MAX_D], dl[MAX_D], dr[MAX_D];

int main() {
	D = podajD();
	R = podajR();

	for (int i = 0; i < D; ++i) {
		dl[i] = 0;
		dr[i] = R;
		E[i] = R / 2;
	}

	while (dr[0] - dl[0] > 1) {
		for (int i = 0; i < D; ++i) {
			int cm = E[i];
			int dd = dr[i] - cm;

			E[i] = dl[i];
			czyCieplo(E);
			E[i] = dr[i];
			if (czyCieplo(E)) {
				dl[i] = dr[i] - dd;
			} else {
				dr[i] = dl[i] + dd;
			}
			E[i] = (dl[i] + dr[i]) / 2;
		}
	}

	for (int i = 0; i < D; ++i) {
		if (dl[i] > 0) {
			E[i] = dl[i] - 1;
			czyCieplo(E);
			E[i] = dr[i];
			if (!czyCieplo(E)) {
				--E[i];
			}
		} else {
			E[i] = dr[i] + 1;
			czyCieplo(E);
			E[i] = dl[i];
			if (!czyCieplo(E)) {
				++E[i];
			}
		}
	}

	znalazlem(E);
}