Uvalive 4954 Lawn mower
2015-09-11 12:20
375 查看
#include <iostream> #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int N,M; double W,x[1010],y[1010]; bool f1,f2; int main(){ while(scanf("%d%d%lf",&N,&M,&W)!=EOF){ if(N==0&&M==0&&W==0){ break; } //cout<<"test: "<<N<<" "<<M<<" "<<W<<"\n"; f1=f2=true; for(int i=1;i<=N;i++){ scanf("%lf",&x[i]); } x[0]=-W/2; x[N+1]=75+W/2; //cout<<"test: "<<x[0]<<" "<<x[N+1]<<"\n"; sort(x,x+N+2); // //for(int i=0;i<N+2;i++) cout<<x[i]<<" "; //cout<<"\n"; // for(int i=0;i<N+1;i++){ if(x[i+1]-x[i]>W){ f1=false; break; } } for(int i=1;i<=M;i++){ scanf("%lf",&y[i]); } y[0]=-W/2; y[M+1]=100+W/2; //cout<<"test: "<<y[0]<<" "<<y[M+1]<<"\n"; sort(y,y+M+2); // //for(int i=0;i<M+2;i++) cout<<y[i]<<" "; //cout<<"\n"; // for(int i=0;i<M+1;i++){ if(y[i+1]-y[i]>W){ f2=false; break; } } if(f1&&f2){ printf("YES\n"); } else printf("NO\n"); } }
相关文章推荐
- UVALive 4244 Party Party Party(HDU 2779 && Sicily 1663)
- UVALive 6741 The Sacrificial Firepits
- UVALive 6800 The Mountain of Gold (bellman_ford判负环)
- Uvalive 6832 Bit String Reordering
- Uvalive 6398 Low Power
- 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(贪心)