#include <iostream> #include "message.h" #include "krazki.h" #define LL long long using namespace std; int main() { int id, non; LL n, h; LL* holes; LL* discs; id = MyNodeId(); n = NumberOfDiscs(); h = PipeHeight(); if(id != 0) return 0; holes = new LL[h]; discs = new LL[n]; for(int i = 0; i < h; ++i) holes[i] = HoleDiameter(i+1); for(int j = 0; j < n; ++j) discs[j] = DiscDiameter(j+1); int j = 0; int last = 0; for(int i = 1; i < h; ++i) holes[i] = min(holes[i], holes[i-1]); for(int i = h-1; i >= 0 && j < n; --i) if(holes[i] >= discs[j]) ++j, last = i; if(j != n) cout << 0 << endl; else cout << last+1 << endl; delete [] holes; delete [] discs; 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 | #include <iostream> #include "message.h" #include "krazki.h" #define LL long long using namespace std; int main() { int id, non; LL n, h; LL* holes; LL* discs; id = MyNodeId(); n = NumberOfDiscs(); h = PipeHeight(); if(id != 0) return 0; holes = new LL[h]; discs = new LL[n]; for(int i = 0; i < h; ++i) holes[i] = HoleDiameter(i+1); for(int j = 0; j < n; ++j) discs[j] = DiscDiameter(j+1); int j = 0; int last = 0; for(int i = 1; i < h; ++i) holes[i] = min(holes[i], holes[i-1]); for(int i = h-1; i >= 0 && j < n; --i) if(holes[i] >= discs[j]) ++j, last = i; if(j != n) cout << 0 << endl; else cout << last+1 << endl; delete [] holes; delete [] discs; return 0; } |