Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///problema nr.1 OLI 13.02
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <algorithm>
- #include <utility>
- using namespace std;
- ifstream f("date.in");
- ofstream g("date.out");
- bool comp(pair<int,int>A, pair<int,int>B)
- {
- if(A.first<B.first)
- return 1;
- else if(A.first==B.first && A.second<B.second)
- return 1;
- return 0;
- }
- vector<pair<int, int>>v;
- int main()
- {
- short n; int x, y;
- f>>n;
- v.resize(n+1);
- short i, j;
- for (i=1; i<=n; ++i)
- {
- f>>x>>y;
- v[i]=make_pair(x, y);
- }
- sort(v.begin(), v.end(), comp);
- int drmax=v[1].second, nrs=0;
- for (i=2; i<=n; ++i)
- {
- if(v[i].second>drmax)
- drmax=v[i].second;
- else
- ++nrs;
- }
- g<<nrs;
- g<<'\n'<<'\n';
- for (i=1; i<=n; ++i)
- g<<v[i].first<<" "<<v[i].second<<'\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement