[Codevs Cup Road] P1368

Source: Internet
Author: User

How do you get the AC without charging?

Title: http://codevs.cn/problem/1368/

Well...... Bubble Hall, very hard ah, in fact, is a pirate field bogey horse racing

Http://www.cnblogs.com/hyfer/p/5853381.html

This blog is very good, although not the problem, but the method is completely similar

You understand the field bogey horse racing, bubble Hall naturally solved.

1#include <cstdio>2#include <cstdlib>3#include <cstring>4#include <cmath>5#include <iostream>6#include <algorithm>7#include <ctime>8#include <queue>9#include <stack>TentypedefLong LongLL; OnetypedefDoubledb; A using namespacestd; -  - Const intoo=2147483647, tl=996, n=100001; the intA[n],b[n]; - intMain () - { -     inti,n,la,lb,ra,rb,ans=0; +scanf"%d",&n); -      for(i=1; i<=n;i++) scanf ("%d",&a[i]); +      for(i=1; i<=n;i++) scanf ("%d",&b[i]); ASort (A + (la=lb=1), A + (ra=rb=n) +1); atSort (b +1, B +1+n); -      while(la<=RA) -     { -         if(a[la]>b[lb]) -         { -ans+=2; inla++; -lb++; to         } +         Else if(a[ra]>B[RB]) -         { thera--; *rb--; $ans+=2;Panax Notoginseng         } -         Elseans+= (a[la++]==b[rb--]); the     } +printf"%d", ans); A      for(i=la=lb=1, ans=0, ra=rb=n;i<=n;i++) Swap (a[i],b[i]); the      while(la<=RA) +     { -         if(a[la]>b[lb]) $         { $ans+=2; -la++; -lb++; the         } -         Else if(a[ra]>B[RB])Wuyi         { thera--; -rb--; Wuans+=2; -         } About         Elseans+= (a[la++]==b[rb--]); $     } -printf"%d\n",2*n-ans); -     return 0; -}

[Codevs Cup Road] P1368

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.