UVA 7261 Xiongnu's Land
来源:互联网 发布:我的淘宝卖家旺旺号 编辑:程序博客网 时间:2024/06/08 07:57
U can find the original link here
this question need us to find a line parallel to y axis that divide the given area of (0,0) to (R,R),witch satsifiy the two conditions:one is the part in left have more green land and make the difference between the two part as small as possible ,another is the left one has more always has more land the the one in the right
so we can scan the whole area to find a divide the green land space just in two ,and find if the line we find can expand .
question give us 1e6 parameter of R but only 1e4 greend land , we can search in the last one ,it’s a smart move
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;const int maxn=1e4+50;typedef long long LL;struct Node{ int l,r,h;};int t,R,n;Node a[maxn];LL cal(int x){ LL sum=0; for(int i=0; i<n; i++) if(a[i].l<x) sum+=(LL)(min(a[i].r,x)-a[i].l)*a[i].h; return sum;}int main(){ scanf("%d",&t); while(t--) { LL sum=0; scanf("%d",&R); scanf("%d",&n); for(int i=0; i<n; i++) { int x,y,w,h; scanf("%d%d%d%d",&x,&y,&w,&h); a[i].l=x,a[i].r=x+w,a[i].h=h; sum+=(LL)w*h; } int l=0,r=R,mid; while(l<r) { mid=(l+r)/2; LL area=cal(mid); if(2*area<sum) l=mid+1; else r=mid; } LL tmp=cal(r); while(cal(r)==tmp&&r<=R) r++; printf("%d\n",r-1); } return 0;}
阅读全文
0 0
- UVA 7261 Xiongnu's Land
- UVALive 7261 Xiongnu's Land 扫描线
- UVALive 7261 A - Xiongnu's Land
- UVALive 7261 Xiongnu's Land(二分)
- 【扫描线】uvalive 7261 Xiongnu's Land
- UVALive 7261 Xiongnu's Land(二分)
- Xiongnu's Land (UVALive
- hiho 1249 Xiongnu's Land
- 二分 hihoCoder1249 Xiongnu's Land
- hihocoder 1249 Xiongnu's Land
- UVALive 7261 A - Xiongnu's Land(二分)
- hihoCoder 1249 Xiongnu's Land(二分)
- Xiongnu's Land (线性扫描,二分)
- 2015 Asia BeiJing Regional Contest A. Xiongnu's Land(二分)
- 2015ACM-ICPC 北京赛区 Problem A. Xiongnu's Land
- ACM-ICPC北京赛区2015 A hihoCoder 1249 Xiongnu's Land
- HDU 5124 hihocoder 1249 Xiongnu's Land (2015北京区域赛A)
- hihocoder 2015ACM-ICPC 北京赛区 Problem A. Xiongnu's Land
- mysql 查询去除表中(多个条件确定的一个数据)
- 50585505
- Excel在统计分析中的应用—第八章—假设检验-方差已知下总体均值的单侧检验
- tcp、udp、socket,关系
- 微信开发时 在页面中 window.location.href 不可用问题
- UVA 7261 Xiongnu's Land
- 点播/直播/VR视频播放器研究(2)-Android
- js分页加载更多
- 封装Integer 和int 的对比
- cadence pcb 总结
- 11月24日学习笔记_map/reduct的应用于使用
- H5移动端横竖屏切换监听 副作用——手机整屏状态下安卓机input 问题
- 谈谈Unicode编码,简要解释UCS、UTF、BMP、BOM等名词
- web项目-Excel文件导出