Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
#include <iostream> #include <sstream> #include <vector> #include <algorithm> #include <climits> #include "krazki.h" #include "message.h" using namespace std; stringstream out; typedef long long ll; struct SmallestDiameter { int number; ll diameter; }; ll holeDiameter[1000000]; ll discDiameter[1000000]; vector<SmallestDiameter> smallestDiameters; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (MyNodeId()) return 0; int pipeHeight, numberOfDiscs; pipeHeight = PipeHeight(); numberOfDiscs = NumberOfDiscs(); for (int i = 0; i < pipeHeight; ++i) holeDiameter[i] = HoleDiameter(i + 1); for (int i = 0; i < numberOfDiscs; ++i) discDiameter[i] = DiscDiameter(i + 1); //Szukanie najmniejszych �rednic od g�ry SmallestDiameter smallestDiameter; int oldNumber = -1; ll smallest = LLONG_MAX; for (int i = 0; i < pipeHeight; ++i) { if (holeDiameter[i] < smallest) { smallestDiameter.number = i - 1; smallestDiameter.diameter = holeDiameter[i]; oldNumber = i; smallest = holeDiameter[i]; smallestDiameters.push_back(smallestDiameter); } } //Wk�adanie kolejnych kr��k�w auto it = smallestDiameters.rbegin(); int minimumPosition = pipeHeight - 1; for (int i = 0; i < numberOfDiscs; ++i) { if (minimumPosition == -1) { minimumPosition = -2; break; } while (it->diameter < discDiameter[i]) { minimumPosition = it->number; ++it; } if (it->number >= minimumPosition) { ++it; } --minimumPosition; } cout << minimumPosition + 2 << endl; 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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #include <iostream> #include <sstream> #include <vector> #include <algorithm> #include <climits> #include "krazki.h" #include "message.h" using namespace std; stringstream out; typedef long long ll; struct SmallestDiameter { int number; ll diameter; }; ll holeDiameter[1000000]; ll discDiameter[1000000]; vector<SmallestDiameter> smallestDiameters; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (MyNodeId()) return 0; int pipeHeight, numberOfDiscs; pipeHeight = PipeHeight(); numberOfDiscs = NumberOfDiscs(); for (int i = 0; i < pipeHeight; ++i) holeDiameter[i] = HoleDiameter(i + 1); for (int i = 0; i < numberOfDiscs; ++i) discDiameter[i] = DiscDiameter(i + 1); //Szukanie najmniejszych �rednic od g�ry SmallestDiameter smallestDiameter; int oldNumber = -1; ll smallest = LLONG_MAX; for (int i = 0; i < pipeHeight; ++i) { if (holeDiameter[i] < smallest) { smallestDiameter.number = i - 1; smallestDiameter.diameter = holeDiameter[i]; oldNumber = i; smallest = holeDiameter[i]; smallestDiameters.push_back(smallestDiameter); } } //Wk�adanie kolejnych kr��k�w auto it = smallestDiameters.rbegin(); int minimumPosition = pipeHeight - 1; for (int i = 0; i < numberOfDiscs; ++i) { if (minimumPosition == -1) { minimumPosition = -2; break; } while (it->diameter < discDiameter[i]) { minimumPosition = it->number; ++it; } if (it->number >= minimumPosition) { ++it; } --minimumPosition; } cout << minimumPosition + 2 << endl; return 0; } |