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
#include <iostream>
#include "krazki.h"
#include "message.h"

using namespace std;

int t[1000001];

int main()
{
  ios_base::sync_with_stdio(0);
  if (MyNodeId()==0)
  {
    int n=PipeHeight();
    int m=NumberOfDiscs();
    int k;
    t[1]=HoleDiameter(1);
    for (int i=2;i<=n;i++)
    {
      t[i]=HoleDiameter(i);
      t[i]=min(t[i-1],t[i]);
    }
    int tmp=n+1;
    //for (int i=1;i<=n;i++) cout << t[i] << " ";
    //cout << endl;
    for (int i=1;i<=m;i++)
    {
      k=DiscDiameter(i);
      tmp--;
      while (t[tmp]<k && tmp>0) tmp--;
      if (tmp==0) break;
      //cout << tmp << endl;
    }
    cout << tmp << endl;
  }
}