Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main()
- {
- int n,g,godziny,minuty,ilosc,ilo=1000,f=0,o_ktorej,check=0;
- char tab1 [5] ;
- cin >> n;
- cin >> g;
- g=g*60;
- int tab[n+1];
- tab[0]=0;
- for (int i=1;i<n+1;i++){
- cin>> tab1;
- godziny=atoi(tab1);
- tab1[0]=tab1[3];
- tab1[1]=tab1[4];
- minuty=atoi(tab1);
- //if ((godziny*60 +minuty>1440-g)&&(check==0)) {
- // check++;
- // tab[i]=1440-g;
- // }
- // else if (godziny*60 +minuty==1440-g) check++;
- //else
- tab[i]= godziny*60 +minuty;
- }
- for(int i=0;i<n+1;i++){
- ilosc=0;
- if (tab[i]>1440-g) break;
- for(f; tab[f]<tab[i]+g; f++){
- ilosc++;
- f++;
- cout<< ilosc<<endl;
- }
- f=i;
- if (ilosc<ilo){
- ilo=ilosc;
- o_ktorej=tab[i];
- }
- }
- cout << o_ktorej/60<<":"<<o_ktorej%60<<endl;
- cout <<ilo;
- return 0;
- }
Add Comment
Please, Sign In to add comment