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

using namespace std;
long long rurka[10000001];
int main()
{
    ios_base::sync_with_stdio(0);
    if(MyNodeId()==0)
    {
        long long n,m,a;
        //cin>>n>>m;
        n=PipeHeight();
        m=NumberOfDiscs();
        long long koniec=n+1;
        rurka[0]=2000000000000000000;
        for(int i=1;i<n+1;i++)
        {
            //cin>>rurka[i];
            rurka[i]=HoleDiameter(i);
            if(rurka[i]>rurka[i-1])rurka[i]=rurka[i-1];
        }
        for(int i=1;i<=m;i++)
        {
            //cin>>a;
            a=DiscDiameter(i);
            while(koniec>0 && a>rurka[koniec-1])
            {
                koniec--;
            }
            if(koniec>0)koniec--;
        }
        cout<<koniec;
    }
}