Messy yyy.

Source: Internet
Author: User

Topic background

Quick Noip, yyy very nervous!

Title Description

Now there are n races on each big OJ, and the beginning and end of each game is known.

YYY believes that the more games you take, the better noip you will be able to test (fake)

So, he wanted to know how many games he could play.

Because YYY is Konjac Konjac, if you want to participate in a competition must finish, and can not participate in 2 or more competitions.

Input/output format

Input format:

The first line is an integer n, and the next n rows are 2 positive integers ai,bi (AI<BI), indicating when the game starts and ends.

Output format:

The maximum number of tournaments that an integer participates in.

Input and Output Sample input example # #:
30 22 41 3
Sample # # of output:
2
Description

For 20% of data, n≤10;

For 50% of data, n≤1000;

For 70% of data, n≤100000;

For 100% of data, n≤1000000,0≤ai

The start time for the second keyword is sorted in ascending order with the end time as the first keyword.

Each game is to participate as long as it determines whether the start time is after the end of the game.

#include <iostream>#include<cstdio>#include<cstring>#include<algorithm>#defineMAXN 1000005using namespacestd;intN;structdata{intx, y;} A[MAXN];intF[MAXN];BOOLcmpConstData A,Constdata B) {    if((A.Y&LT;B.Y) | | ((A.Y==B.Y) && (a.x<b.x )))return 1;//Judgment End Time    Else return 0; }intMain () {CIN>>N;  for(intI=1; i<=n;++i) scanf ("%d%d",&a[i].x,&a[i].y); Sort (a+1, A +1+n,cmp); intk=0, l=0;  for(intI=1; i<=n;++i)if(k<=a[i].x) {k=a[i].y; ++l; } cout<<M; return 0;}
Rokua P1803

Messy yyy.

Related Keywords:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.