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
#include <bits/stdc++.h>
#include "krazki.h"
#include "message.h"

using namespace std;

typedef long long LL;

LL t[30000005];

int main()
{
	int n, m;
	if(!MyNodeId())
	{
	n = NumberOfDiscs();
	m = PipeHeight();
	t[0] = 1123456789123456789LL;
	for(int i = 1; i <= m; ++i)
		t[i] = min(HoleDiameter(i), t[i-1]);
	int pos = m;
	LL poprz = 0LL;
	int res = m;
	for(int i = n - 1; i >= 0; --i)
	{
		LL a = DiscDiameter((n - i));
		if(a <= poprz)
			continue;
		poprz = a;
		while(t[pos] < a) pos--;
		res = min(res, pos - i);
	}
	printf("%d", max(res, 0));
	}
}