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
#include <cstdlib>
#include <iostream>

#include "krazki.h"
#include "message.h"

int main() {
  if (MyNodeId() != 0) {
    return EXIT_SUCCESS;
  }
  int n,m;
  long long a,b,c,prev,i,j;
	n = PipeHeight();
	m = NumberOfDiscs();
	long long* mins = new long long [n+1];
	mins[0] = HoleDiameter(1);

	for (i=1;i<n;i++)
	{
		mins[i] = HoleDiameter(i+1);
		mins[i] = mins[i] < mins[i-1] ? mins[i] : mins[i-1]; 
	}
	a = n;
	for (j=0;j<m;j++)
	{
		b = DiscDiameter(j+1);
		while (a>0 && mins[a - 1] < b)
			a--;
		a--;
	}
	a = 0 > a + 1 ? 0 : a + 1;
	std::cout << a << std::endl;
	return EXIT_SUCCESS;
}