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
#include <bits/stdc++.h>
#include "krazki.h"
#include "message.h"

using namespace std;

#define EB emplace_back

int main()
{
    vector <long long> xD;
    xD.EB(HoleDiameter(1));
    for(int i = 2; i <= PipeHeight(); ++i)
    {
        xD.EB(HoleDiameter(i));
        if(xD[i - 2] < HoleDiameter(i))
            xD[i - 1] = xD[i - 2];
    }
    vector <long long> Pipe;
    for(int i = PipeHeight() - 1; i >= 0; --i)
        Pipe.EB(xD[i]);
    vector<long long>::iterator it1 = Pipe.begin();
    for(int i = 1; i <= NumberOfDiscs(); ++i)
    {
        it1 = lower_bound(it1, Pipe.end(), DiscDiameter(i));
        if(it1 == Pipe.end())
            break;
        it1++;
    }
    if(it1 == Pipe.end())
        return cout << 0, 0;
    else
        return cout << distance(it1, Pipe.end()) + 1, 0;
}