#include <bits/stdc++.h> #include "krazki.h" #include "message.h" using namespace std; int main() { if (MyNodeId() != 0) { return EXIT_SUCCESS; } int n = PipeHeight(); int m = NumberOfDiscs(); vector<long long> hole(n + 1); long long l = HoleDiameter(1); for(int i = 1; i <= n; i++) { hole[i] = min(l, HoleDiameter(i)); l = min(l, hole[i]); } int i = n, j = 1; while(i > 0 && j <= m) { if (DiscDiameter(j) <= hole[i]) { j++; } i--; } if (j == m + 1) { i++; } cout << i << std::endl; return EXIT_SUCCESS; }
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 | #include <bits/stdc++.h> #include "krazki.h" #include "message.h" using namespace std; int main() { if (MyNodeId() != 0) { return EXIT_SUCCESS; } int n = PipeHeight(); int m = NumberOfDiscs(); vector<long long> hole(n + 1); long long l = HoleDiameter(1); for(int i = 1; i <= n; i++) { hole[i] = min(l, HoleDiameter(i)); l = min(l, hole[i]); } int i = n, j = 1; while(i > 0 && j <= m) { if (DiscDiameter(j) <= hole[i]) { j++; } i--; } if (j == m + 1) { i++; } cout << i << std::endl; return EXIT_SUCCESS; } |