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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<bits/stdc++.h>
#include "krazki.h"
#include "message.h"
#define ll long long
#define ld long double
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.precision(20);
#define inf 1000000007
#define INF 1000000000000000000LL
#define mod 1000000007
#define VI vector<int>
#define VPI vector < pair<int,int> >
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define REP(x, y) for(int x = 0; x < (y); ++x)
#define FOR(x, y, z) for(int x = y; x <= (z); ++x)
#define FORR(x, y, z) for(int x = y; x >= (z); --x)
using namespace std;
#define int long long

int n,m,x,pom;
int tab[25000007];

#undef int
int main()
{
  #define int long long
  boost

  n=PipeHeight();
  m=NumberOfDiscs();
  tab[0]=HoleDiameter(1);

  FOR(i,1,n-1) 
  {
     tab[i]=HoleDiameter(i+1);
     tab[i] = min(tab[i], tab[i-1]);
  }

    pom=n;

  FOR(i,1,m) 
  {
     x=DiscDiameter(i);
     while (pom>0 && tab[pom-1]<x) 
     pom--;

     pom--;
  }
  if (MyNodeId()==0)
  cout << max((ll)0, pom + 1) << endl;
  return 0;
}