Uvalive 6398 Low Power
2015-09-08 12:18
429 查看
#include <iostream> #include <cstdio> #include <ctime> #include <cstring> #include <algorithm> using namespace std; const int MAXN=1000010; int P[MAXN]; int N,K,num,ans; bool fun(int mi){ for(int i=0,j=0,lab=1;i<N;i++,lab+=(2*K)){ for(;j<lab;j++){ if(P[j+1]-P[j]<=mi){ j+=2; break; } } if(j==lab){ return false; } } return true; } int main(){ while(scanf("%d%d",&N,&K)!=EOF){ num=2*N*K; for(int i=0;i<num;i++){ scanf("%d",&P[i]); } sort(P,P+num); int l=0,r=P[num-1]; while(l<=r){ int mid=(l+r)>>1; if(fun(mid)){ ans=mid; r=mid-1; } else{ l=mid+1; } } printf("%d\n",ans); } return 0; }
相关文章推荐
- UVALive 4244 Party Party Party(HDU 2779 && Sicily 1663)
- UVALive 6741 The Sacrificial Firepits
- UVALive 6800 The Mountain of Gold (bellman_ford判负环)
- Uvalive 6929 Sums
- UVALive 5135 - Mining Your Own Business(点双连通)
- UVALive 4287 - Proving Equivalences(强连通分量)
- UVALive 3713 - Astronauts(2-SAT)
- UVALive 3211 - Now or later(2-SAT + 二分)
- UVALive 4727 Jump
- UVALive 3530 Martian Mining
- UVALive 6163 - Myth Busters
- UVALive 2038 Strategic game
- UVALive 4394 String painter
- UVALive 4327 Parade(hdu 2490 Parade)
- UVALive 4015 Caves
- HDU 1665 or UVALive 3263 || That Nice Euler Circuit (欧拉定理求面数 F = E+2-V
- UVALive 4487 Exclusive-OR
- uvalive 2757(贪心)
- uvalive 4324
- uvalive 4328(贪心)