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