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
#include <bits/stdc++.h>
#include "message.h"
#include "krazki.h"
//#include "krazki.cpp"
using namespace std;

const int nodes = NumberOfNodes();
const int my_id = MyNodeId(); 

int n, m;

int main () {
	n = PipeHeight();
	m = NumberOfDiscs();

	if (my_id == 0) {
		vector<long long> v(n, 0LL);
		v[0] = HoleDiameter(1);
		for (int i = 1; i < n; i++) {
			v[i] = HoleDiameter(i + 1);
			v[i] = min(v[i], v[i - 1]);
		}
		int d = n;
		for (int i = 0; i < m; i++) {
			long long x = DiscDiameter(i + 1);
			while (d > 0 && v[d - 1] < x) --d;
			--d;
		}
		printf("%d\n", max(0, d + 1));
	}

	return 0;
}