A guest in the Heavenly Palace

Source: Internet
Author: User

A guest in the Heavenly Palace Topic Description One day, I had a dream, dreamed I was honored to receive the invitation of pig, to the Heavenly Palace accompany him to eat wine. I hesitated. One day in the sky, a year on earth! Of course, I am an idler, there is not much time in a year is to be in the world, therefore, I would like to choose a maximum free time period, so that I stay in the sky as long as possible. Remember, this year is 4,000 years. The sky is also 24 hours a day, 60 minutes per hour, 60 seconds per minute. Enter the first line is a non-negative integer N, indicating the number of days that must stay in the world in 4000, the following total N lines, each line two spaces separated by a positive integer, that is, the date (month, day), the input guarantee error-free, date no duplicates. The output has only one row containing a non-negative integer, which is the time in the sky (rounded down to seconds). Sample input
23 812 2
Sample output
63266
Analysis: Simulation can, pay attention to the two ends of the boundary situation;
Code:
#include <iostream>#include<cstdio>#include<cstdlib>#include<cmath>#include<algorithm>#include<climits>#include<cstring>#include<string>#include<Set>#include<map>#include<queue>#include<stack>#include<vector>#include<list>#include<bitset>#defineRep (I,m,n) for (i=m;i<=n;i++)#defineRSP (It,s) for (Set<int>::iterator It=s.begin (); It!=s.end (); it++)#defineVI vector<int>#definePII pair<int,int>#defineMoD 1000000007#defineINF 0x3f3f3f3f#definePB Push_back#defineMP Make_pair#defineFi first#defineSe Second#definell Long Long#definePi ACOs (-1.0)Const intmaxn=1e5+Ten;Const intdis[4][2]={{0,1},{-1,0},{0,-1},{1,0}};using namespacestd;ll gcd (ll p,ll q) {returnq==0? P:GCD (q,p%q);} ll Qpow (ll p,ll q) {ll F=1; while(q) {if(q&1) f=f*p;p=p*p;q>>=1;}returnF;}intN,m,k,t,ma;pii A[MAXN];BOOLcmpConstPii&p,Constpii&q) {    returnp.fi==q.fi?p.se<q.se:p.fi<q.fi;}intCheckinta) {    if(a==2)return  in; Else if(a==1|| a==3|| a==5|| a==7|| a==8|| a==Ten|| a== A)return  to; Else return  -;}intCountintPintq) {    intnow1=0, now2=0;  for(intI=1; i<a[p].fi;i++) now1+=check (i); Now1+=a[p].se;  for(intI=1; i<a[q].fi;i++) now2+=check (i); Now2+=a[q].se; returnNow2-now1-1;}intMain () {inti,j; scanf ("%d",&N); a[0].fi=a[0].se=0; Rep (I,0, N-1) scanf ("%d%d",&a[i].fi,&a[i].se); A[n+1].fi= A; a[n+1].se= +; Sort (A,a+n+2, CMP); Rep (I,0, N) {Ma=max (Ma,count (i,i+1)); }    //printf ("%d\n", MA); //if (n==0) return 0*printf ("%d\n", 24*3600);printf"%.0f\n",1.0*ma* -*3600/366); //System ("pause");    return 0;}

A guest in the Heavenly Palace

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.