#include<bits/stdc++.h>
#include <cstdlib>
#include "krazki.h"
#include "message.h"
#define pb push_back
#define mp make_pair
#define f first
#define s second
using namespace std;
int main()
{
if (MyNodeId() != 0)
{
return EXIT_SUCCESS;
}
int n=PipeHeight();
int m=NumberOfDiscs();
//scanf("%d%d",&n,&m);
long long otwor[n+1];
otwor[1]=HoleDiameter(1);
for(int a=2; a<=n; a++)
otwor[a]=min(HoleDiameter(a),otwor[a-1]);
int poprzedni=n+1,b;
long long t;
for(int a=1; a<=m; a++)
{
t=DiscDiameter(a);
b=poprzedni-1;
while(b>0 && t>otwor[b])
b--;
poprzedni=b;
if(poprzedni==0)
{
printf("0");
return EXIT_SUCCESS;
}
}
printf("%d",poprzedni);
return EXIT_SUCCESS;
}
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 | #include<bits/stdc++.h> #include <cstdlib> #include "krazki.h" #include "message.h" #define pb push_back #define mp make_pair #define f first #define s second using namespace std; int main() { if (MyNodeId() != 0) { return EXIT_SUCCESS; } int n=PipeHeight(); int m=NumberOfDiscs(); //scanf("%d%d",&n,&m); long long otwor[n+1]; otwor[1]=HoleDiameter(1); for(int a=2; a<=n; a++) otwor[a]=min(HoleDiameter(a),otwor[a-1]); int poprzedni=n+1,b; long long t; for(int a=1; a<=m; a++) { t=DiscDiameter(a); b=poprzedni-1; while(b>0 && t>otwor[b]) b--; poprzedni=b; if(poprzedni==0) { printf("0"); return EXIT_SUCCESS; } } printf("%d",poprzedni); return EXIT_SUCCESS; } |
English