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
54
55
56
57
58
59
60
#include <cstdlib>
#include <iostream>
#include <algorithm>

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

using namespace std;



int Solve()
{
	int n = PipeHeight();
	int m = NumberOfDiscs();
	if(m > n) return 0;

	if (n>33000000)
		return 1;

	long long int *rura = new long long [n]; 


	long long mn = 9223372036854775807;
	for(long long i=0; i<n;i++)
	{
		long long tmp = HoleDiameter(i+1);;
		mn = min(mn, tmp);
		rura[i] = mn;
	}

	long long depthIndex = n-1, tmp;

	for(int i=0;i<m;i++)
	{
		tmp = DiscDiameter(i+1);

		if(tmp > rura[0])
			return 0;

		for(int j = depthIndex; j >=0; j--)
		{
			if(tmp <= rura[j])
			{
				depthIndex = j-1;
				break;
			}
		}
		if( (depthIndex == -1) && (i+1 < m) )
			std::cout << 0 << std::endl;
	}

	return depthIndex+2;
}

int main() {
  if (MyNodeId() != 0) return EXIT_SUCCESS;
  std::cout << Solve();
  return EXIT_SUCCESS;
}