Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n,g,godziny,minuty,ilosc,ilo=1000,f=0,o_ktorej,check=0;
  8. char tab1 [5] ;
  9. cin >> n;
  10. cin >> g;
  11. g=g*60;
  12. int tab[n+1];
  13. tab[0]=0;
  14. for (int i=1;i<n+1;i++){
  15. cin>> tab1;
  16. godziny=atoi(tab1);
  17. tab1[0]=tab1[3];
  18. tab1[1]=tab1[4];
  19. minuty=atoi(tab1);
  20. //if ((godziny*60 +minuty>1440-g)&&(check==0)) {
  21. // check++;
  22. // tab[i]=1440-g;
  23. // }
  24. // else if (godziny*60 +minuty==1440-g) check++;
  25. //else
  26. tab[i]= godziny*60 +minuty;
  27. }
  28. for(int i=0;i<n+1;i++){
  29. ilosc=0;
  30. if (tab[i]>1440-g) break;
  31.  
  32. for(f; tab[f]<tab[i]+g; f++){
  33. ilosc++;
  34. f++;
  35. cout<< ilosc<<endl;
  36. }
  37.  
  38. f=i;
  39. if (ilosc<ilo){
  40. ilo=ilosc;
  41. o_ktorej=tab[i];
  42. }
  43. }
  44. cout << o_ktorej/60<<":"<<o_ktorej%60<<endl;
  45. cout <<ilo;
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment