• API
• FAQ
• Tools
• Archive
A Pastebin account makes a great Christmas gift
SHARE
TWEET

# Untitled

a guest Nov 14th, 2017 78 Never
ENDING IN00days00hours00mins00secs

1. // uloha8.c -- William Brach, 6.11.2017 13:40
2.
3.
4. #include <stdio.h>
5. #include <math.h>
6.
7. struct Jablko{
8.   double x;
9.   double y;
10.   double t;
11.   };
12.
13. struct Jablko pole[10001];
14. int pocetjablk,max[10001];
15. double rychlost;
16.
17. double pytagoras(double x1, double y1, double x2, double y2)
18. {
19.   double vysledok;
20.   vysledok = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) );
21.   return vysledok;
22. }
23.
24. int porovnanie(const void *va, const void *vb)
25. {
26.   struct Jablko *a = (struct Jablko *)va, *b = (struct Jablko *)vb;
27.   if (a->t > b->t)
28.     return 1;
29.   if (a->t < b->t)
30.     return -1;
31.   return 0;
32. }
33.
34. int main()
35. {
36.   // sem napis svoje riesenie
37.   int i,j;
38.   double vzdialenost,cas,cas2;
39.   while(scanf("%d %lf", &pocetjablk, &rychlost) > 0)
40.   {
41.     max[0]=1;
42.     for(i=1;i<=pocetjablk;i++)
43.       max[i] = 0;
44.
45.     for (i = 1; i <=pocetjablk; i++)
46.       scanf("%lf %lf %lf", &pole[i].x,&pole[i].y,&pole[i].t);
47.     qsort(&pole,pocetjablk+1,sizeof(struct Jablko),porovnanie);
48.
49.
50.     for(i=1;i<=pocetjablk;i++)
51.     {
52.       for(j=0;j<i;j++)
53.         if(max[i] < max[j]+1 && max[j])
54.         {
55.           vzdialenost = pytagoras(pole[i].x,pole[i].y,pole[j].x,pole[j].y);
56.
57.           cas = vzdialenost / rychlost;
58.           cas2 = pole[i].t - pole[j].t;
59.           if (cas <= cas2)
60.             max[i] = max[j]+1;
61.         }
62.     }
63.   j = max[0];
64.   for(i = 1;i <= pocetjablk;i++)
65.   if (max[i] > j)
66.     j = max[i];
67.   printf("%d\n",j-1);
68.   }
69.
70.   return 0;
71. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top