ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

HDU4312 Meeting point-2 (ÇбÈÑ©·ò¾àÀë&&Âü¹þ¶Ù¾àÀë)
2015-07-20 17:23:25 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:1´Î
Tags£ºHDU4312 Meeting point-2 ¾àÀë & Âü¹þ¶Ù

ÌâÄ¿Á´½Ó£º

www.2cto.com

ÌâÒ⣺¸ø¶¨Æ½Ãæ×ø±êÉÏn£¨n<=100000£©¸öµã£¬È»ºóÔÚÆäÖÐѡһ¸ö£¬Ê¹µÃËùÓе㵽µ±Ç°µãµÄChebyshev¾àÀëºÍ×îС¡£

?

·ÖÎö£º

ÇбÈÑ©·ò¾àÀ룺Éèa(x1,y1),b(x2,y2);DIS = max(|x1-x2|,|y1-y2|) = (|x1-x2+y1-y2|+|x1-x2-y1+y2|)/2;

ÎÒÃǽ«µãaaµÄ×ø±ê¿´³É£¨x1+y1,x1-y1£©,bbµÄ×ø±ê¿´³É£¨x2+y2,x2-y2£©,´Ó¼¸ºÎÒâÒåÉϽ²Ï൱ÓÚµãÔÚÔ­

×ø±êϵÉÏÄæÊ±ÕëÐýת45¶È£¬²¢½«×ø±êÀ©´ó¡Ì2±¶¡£

È»ºóÇóеĵÄ×îСµÄÂü¹þ¶Ù¾àÀëºÍµÄÒ»°ë¼´¿É¡£

?

´úÂëÈçÏ£º

?

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; typedef long long LL; const int maxn = 1e5+10; struct point{ int x,y; LL sum; }p[maxn]; bool cmp1(point A,point B) { if(A.x
       
        = 1; --i) { p[i].sum += sum - (n-i) * p[i].x; sum += p[i].x; } sum = 0; sort(p+1, p+1+n, cmp2); for (LL i = 1; i <= n; ++i) { p[i].sum += (i-1) * p[i].y -sum; sum += p[i].y; } sum = 0; LL ans = 1LL<<62; for (LL i = n; i >= 1; --i) { p[i].sum += sum - (n-i) * p[i].y; ans = min(ans, p[i].sum); sum += p[i].y; } printf(%I64d ,ans/2); } return 0; } 
       
      
     
    
   
  

?

?

?

?

??
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºZOJ 1037 && HDU 1046 Gr.. ÏÂһƪ£ºNSArray - Êý×é

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Spring Boot Java£º (2025-12-26 16:20:19)
¡¤Spring Boot¤ÇHello (2025-12-26 16:20:15)
¡¤Spring ¤Î»ù±¾¤«¤éŒ (2025-12-26 16:20:12)
¡¤C++Ä£°å (template) (2025-12-26 15:49:49)
¡¤C ÓïÑÔÖÐÄ£°åµÄ¼¸ÖÖ (2025-12-26 15:49:47)