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
57
58
59
60
61
62
63
64
65
#include <vector>
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
vector<long long int> v;
unsigned long long int n,m;

#include "krazki.h"
#include "message.h"

/*
int MyNodeId(){
  return 0;
}

int PipeHeight() {
  return 5;
}

int NumberOfDiscs(){
  return 3;
}

long long HoleDiameter(long long i){
  long long t[] {5,6,4,3,6,2,3};
  return t[i-1];
}

long long DiscDiameter(long long i){
  long long t[] = {4,1,1,1,1,1,1,1,1,1};
  return t[i-1];
}
*/
int main() {
  if(MyNodeId()!=0)
    return 0;

  n = PipeHeight();
  m = NumberOfDiscs();

  v.push_back(HoleDiameter(1));
  for(unsigned long long int i = 2; i<=n; ++i){
    v.push_back(HoleDiameter(i));
    if(v[i-1-1] < v[i-1])
      v[i-1] = v[i-1-1];
  }
  reverse(v.begin(), v.end());

  auto lastkloc = v.begin();
  for(unsigned long long int i = 1; i<=m; ++i){

    if(lastkloc == (v.end())){
      cout<<0<<"\n";
      return 0;
    }
    lastkloc = (lower_bound(lastkloc, v.end(), DiscDiameter(i)));
    lastkloc++;
    
  }
  //clog<<"fit\n";
  int o = 1;
  for(auto it = lastkloc; it != v.end(); ++it){++o;}
  cout<<(o<0? 0 : o)<<"\n";
}