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

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

using namespace std;

int main()
{
  if(MyNodeId() != 0) return 0;
  int n = PipeHeight();
  int m = NumberOfDiscs();
  vector<long long> w(n, 0);
  w[0] = HoleDiameter(1);  

  for (int i = 1; i < n; i++) {
    w[i] = min(HoleDiameter(i + 1), w[i-1]);
  }

  
  int d = n;
  for (int i = 0; i < m; i++) {    
    while (d>0 && w[d-1]< DiscDiameter(i + 1)) d--;
    d--;
  }

  printf("%d\n", max(0, d + 1));
  return 0;
}