Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream fin("spectacole.in");
- ofstream fout("spectacole.out");
- struct interval
- {
- int x,y;
- };
- interval a[101];
- int n;
- void citeste()
- {
- fin>>n;
- for(int i=1;i<=n;i++)
- fin>>a[i].x>>a[i].y;
- }
- void Sortare()
- {
- int i,j;
- for(i=1;i<n;i++)
- for(j=i+1;j<=n;j++)
- if(a[i].y>a[j].y)
- swap(a[i],a[j]);
- }
- void Greedy()
- {
- int i,k,cnt=1;
- k=1;
- for(i=2;i<=n;i++)
- if(a[k].y<=a[i].x)
- {
- k=i;
- cnt++;
- }
- fout<<cnt;
- }
- int main()
- {
- citeste();
- Sortare();
- Greedy();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement