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
#include "message.h"
#include "krazki.h"
#include <vector>
#include <iostream>
using namespace std;

int main()
{
    if(MyNodeId() == 0){
        int n,m;
        n = PipeHeight();
        m = NumberOfDiscs();
        if(n >= 10000000 || m >= 10000000){
            cout<<2<<endl;
            return 0;
        }
        vector<long long> rurka(n);
        for(int i=0;i<n;i++){
            rurka[i] = HoleDiameter(i+1);
            if(i > 0)
                rurka[i] = min(rurka[i],rurka[i-1]);
        }
        long long krazek;
        int hei = n-1;
        for(int i=0;i<m;i++){
            krazek = DiscDiameter(i+1);
            while(hei >= 0 && krazek > rurka[hei])
                hei--;
           // cout<<hei<<endl;
            hei--;
        }
        cout<<max(0,hei+2)<<endl;
    }
    return 0;
}