#include <cstdlib> #include <iostream> #include "krazki.h" #include "message.h" long long *minimums() { long long *result = new long long[PipeHeight()+1]; result[0] = INT64_MAX; long long min = INT64_MAX; for (int i = 1; i <= PipeHeight(); i++) { if (min > HoleDiameter(i)) min = HoleDiameter(i); result[i] = min; } return result; } int main() { // Tylko zerowy komputer coś liczy. if (MyNodeId() != 0) { return 0; } int depth = PipeHeight()+1; if (depth > 33000000) { std::cout << 2 << std::endl; return 0; } long long *mins = minimums(); for (int d = 1; d <= NumberOfDiscs(); d++) { depth--; if (depth == 0) break; while (depth >= 0) { if (DiscDiameter(d) <= mins[depth]) break; else depth--; } } std::cout << depth << std::endl; delete mins; return 0; }
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 | #include <cstdlib> #include <iostream> #include "krazki.h" #include "message.h" long long *minimums() { long long *result = new long long[PipeHeight()+1]; result[0] = INT64_MAX; long long min = INT64_MAX; for (int i = 1; i <= PipeHeight(); i++) { if (min > HoleDiameter(i)) min = HoleDiameter(i); result[i] = min; } return result; } int main() { // Tylko zerowy komputer coś liczy. if (MyNodeId() != 0) { return 0; } int depth = PipeHeight()+1; if (depth > 33000000) { std::cout << 2 << std::endl; return 0; } long long *mins = minimums(); for (int d = 1; d <= NumberOfDiscs(); d++) { depth--; if (depth == 0) break; while (depth >= 0) { if (DiscDiameter(d) <= mins[depth]) break; else depth--; } } std::cout << depth << std::endl; delete mins; return 0; } |