CF History Problem Solving report

Source: Internet
Author: User

This is actually a simple simulation, but our first turn is over, later seniors Rejudge, we again tle, this look not only delayed our time, also fluctuation to our mood, the original time is 2s, (the original OJ is 2s), and then changed to 1s, I used the O (n*n) cycle directly timed out , this is not scary, we are misled by this idea, has been optimized on the basis of O (N*n), made several times .... Finally know that is not so complicated, the problem of the sample is very special, after the direct O (N) enumeration can be, because the water penalty when more, ranked particularly by the back, my heart good pain t ....

#include <iostream>#include<cstdio>#include<algorithm>using namespacestd;structedge{intSt,en;} e[100010];BOOLCMP (EDGE A,edge b) {returnA.St <;}intMain () {intT; scanf ("%d",&t);  for(inti =0; I < t;i++) {scanf ("%d%d",&e[i].st,&e[i].en); } sort (E,e+t,cmp); intAns =0; EDGE Now= e[0];  for(inti =1; I < t;i++)    {        if(E[i].en <Now.en) {ans++; }        Elsenow =E[i]; } printf ("%d\n", ans); return 0;}

CF History Problem Solving report

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: 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.