Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <algorithm>
- using namespace std;
- struct interval
- {
- int x, y;
- };
- interval a[16005];
- inline bool cmp(const interval A, const interval B)
- {
- if (A.x == B.x)
- return A.y < B.y;
- return A.x < B.x;
- }
- int main()
- {
- int n, i, cnt, x1, y1;
- ifstream fin("granita.in");
- fin >> n;
- for(i = 1; i <= n; i++)
- fin >> a[i].x >> a[i].y;
- sort(a + 1, a + n + 1, cmp);
- fin.close();
- cnt = 0;
- x1 = a[1].x;
- y1 = a[1].y;
- for(i = 2; i <= n; i++)
- {
- if(x1 < a[i].x && y1 > a[i].y) cnt++;
- else
- {
- x1 = a[i].x;
- y1 = a[i].y;
- }
- }
- ofstream fout("granita.out");
- fout << cnt << "\n";
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment