Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- struct com{
- int ini, fin;
- };
- bool compara(com a, com b){
- return a.fin<b.fin;
- }
- com consulta[1004];
- int n, livre, qtd;
- int main(){
- cin >> n;
- for(int i=1;i<=n;i++){
- cin >> consulta[i].ini >> consulta[i].fin;
- }
- sort(consulta+1,consulta+n+1, compara);
- for(int i=1;i<=n;i++){
- if(consulta[i].ini>=livre){
- qtd++;
- livre=consulta[i].fin;
- }
- }
- cout << qtd << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement