Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct timp{int h,m,x;};
- struct {timp s,f;int cod;}v[101];
- int n,i,j,sol[101],k;
- void greedy()
- {
- k=1;
- sol[1]=1;
- int j=1;
- for(int i=1;i<=n;i++)
- if(v[i].s.x>=v[j].f.x)
- {
- sol[++k]=i;
- j=i;
- }
- }
- int main()
- {
- //citire
- cin>>n;
- for(i=1;i<=n;i++)
- {
- v[i].cod=i;
- cin>>v[i].s.h>>v[i].s.m;
- v[i].s.x=v[i].s.h*60+v[i].s.m;
- cin>>v[i].f.h>>v[i].f.m;
- v[i].f.x=v[i].f.h*60+v[i].f.m;
- }
- //sortare
- for(i=1;i<n;i++)
- for(j=i+1;j<=n;j++)
- if(v[i].f.x>v[j].f.x) swap(v[i],v[j]);
- greedy();
- //afisare
- for(i=1;i<=k;i++)
- cout<<endl<<v[sol[i]].cod<<' '<<v[sol[i]].s.h<<' '<<v[sol[i]].s.m<<" - "
- <<v[sol[i]].f.h<<' '<<v[sol[i]].f.m;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement