#include<iostream> #include<vector> #include "krazki.h" #include "message.h" using namespace std; int main() { ios_base::sync_with_stdio(0); if(MyNodeId() == 0) { long long n = PipeHeight(); long long m = NumberOfDiscs(); vector<long long> A; A.push_back(0); A.push_back( HoleDiameter(1) ); for(long long i=2; i<=n; i++) { long long a = min(A[i-1], HoleDiameter(i)); A.push_back(a); } long long q = n+1; long long p = 0; for(long long i = 1; i<=m; i++) { p = q -1; long long diam = DiscDiameter(i); while(p > 0 && diam > A[p]) { p--; } q = p; if( q == 0) { break; } } cout<<p<<endl; return 0; } else 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 | #include<iostream> #include<vector> #include "krazki.h" #include "message.h" using namespace std; int main() { ios_base::sync_with_stdio(0); if(MyNodeId() == 0) { long long n = PipeHeight(); long long m = NumberOfDiscs(); vector<long long> A; A.push_back(0); A.push_back( HoleDiameter(1) ); for(long long i=2; i<=n; i++) { long long a = min(A[i-1], HoleDiameter(i)); A.push_back(a); } long long q = n+1; long long p = 0; for(long long i = 1; i<=m; i++) { p = q -1; long long diam = DiscDiameter(i); while(p > 0 && diam > A[p]) { p--; } q = p; if( q == 0) { break; } } cout<<p<<endl; return 0; } else return 0; } |