#include <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; #include "krazki.h" #include "message.h" int main() { //testInit(); if (MyNodeId() > 0) return 0; int d = PipeHeight(); vector<long long> v(d); v[0] = HoleDiameter(1); for (int i=1; i<d; ++i) v[i] = std::min(v[i-1], HoleDiameter(i+1)); int n = NumberOfDiscs(); int res = d - 1; for (int i=1; i<=n; ++i) { long long x = DiscDiameter(i); while (res >= 0 && v[res] < x) --res; --res; if (res < -1) break; } printf("%d\n", res + 2); 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 <cstdio> #include <vector> #include <map> #include <set> #include <queue> #include <algorithm> #include <string> #include <sstream> #include <cmath> using namespace std; #include "krazki.h" #include "message.h" int main() { //testInit(); if (MyNodeId() > 0) return 0; int d = PipeHeight(); vector<long long> v(d); v[0] = HoleDiameter(1); for (int i=1; i<d; ++i) v[i] = std::min(v[i-1], HoleDiameter(i+1)); int n = NumberOfDiscs(); int res = d - 1; for (int i=1; i<=n; ++i) { long long x = DiscDiameter(i); while (res >= 0 && v[res] < x) --res; --res; if (res < -1) break; } printf("%d\n", res + 2); return 0; } |