Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
722 B
22
Indexable
Never
#include <bits/stdc++.h>

using namespace std;

vector <pair<int,int> > oreSp;

bool cmp(pair<int,int> x, pair<int,int> y){
    return (x.second<y.second) || (x.second==y.second && x.first>y.first);
}
int main()
{
    ifstream fin("spectacole.in");
    ofstream fout("spectacole.out");
    int n, x=-1, y=-1, cnt=0;
    fin>>n;
    for(int i=0; i<n; i++){
        fin>>x>>y;
        oreSp.push_back({x, y});
    }
    sort(oreSp.begin(), oreSp.end(), cmp);

    for(int i=0; i<oreSp.size(); i++){
        if(oreSp[i].second<=oreSp[i+1].second){
            cnt++;
        }
        fout<<oreSp[i].first<<" "<<oreSp[i].second<<endl;
    }
    fout<<endl;
    fout<<cnt;



    return 0;
}