#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<deque>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<vector>
#include "krazki.h"
#include "message.h"
using namespace std;
typedef long long LL;
typedef long double LD;
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
int cond = 1;
#define DB(X) {if(cond){cerr<<"Line:"<<__LINE__<<", "<<#X<<" = "<<X<<endl;}}
int solve() {
return 0;
}
int main() {
if (MyNodeId() == 0) {
int p = PipeHeight();
int n = NumberOfDiscs();
vector<pair<LL, LL> > pipe;
for(int i = 0; i < p; ++i) {
LL pp = HoleDiameter(i + 1);
pipe.push_back({pp, i});
}
sort(pipe.begin(), pipe.end());
LL pos = p+1;
LL pp = 0;
for(int j = 0; j < n; ++j) {
LL d = DiscDiameter(j + 1);
pos--;
while (pp < p) {
pair<LL,LL> as = pipe[pp];
if (as.second > p) {
pp++;
continue;
}
if (as.first < d) {
pos = min(pos, as.second);
pp++;
}
else {
break;
}
}
}
cout << (pos < 0 ? 0 : pos);
}
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 | #include<algorithm> #include<cassert> #include<cctype> #include<cmath> #include<cstdio> #include<cstdlib> #include<cstring> #include<deque> #include<iostream> #include<list> #include<map> #include<queue> #include<set> #include<string> #include<vector> #include "krazki.h" #include "message.h" using namespace std; typedef long long LL; typedef long double LD; #define dprintf(...) fprintf(stderr, __VA_ARGS__) int cond = 1; #define DB(X) {if(cond){cerr<<"Line:"<<__LINE__<<", "<<#X<<" = "<<X<<endl;}} int solve() { return 0; } int main() { if (MyNodeId() == 0) { int p = PipeHeight(); int n = NumberOfDiscs(); vector<pair<LL, LL> > pipe; for(int i = 0; i < p; ++i) { LL pp = HoleDiameter(i + 1); pipe.push_back({pp, i}); } sort(pipe.begin(), pipe.end()); LL pos = p+1; LL pp = 0; for(int j = 0; j < n; ++j) { LL d = DiscDiameter(j + 1); pos--; while (pp < p) { pair<LL,LL> as = pipe[pp]; if (as.second > p) { pp++; continue; } if (as.first < d) { pos = min(pos, as.second); pp++; } else { break; } } } cout << (pos < 0 ? 0 : pos); } return 0; } |
English