博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 2482 Stars in Your Window 线段树扫描线
阅读量:5995 次
发布时间:2019-06-20

本文共 6425 字,大约阅读时间需要 21 分钟。

Stars in Your Window

Time Limit: 1 Sec  Memory Limit: 256 MB

题目连接

http://poj.org/problem?id=2482

Description

Fleeting time does not blur my memory of you. Can it really be 4 years since I first saw you? I still remember, vividly, on the beautiful Zhuhai Campus, 4 years ago, from the moment I saw you smile, as you were walking out of the classroom and turned your head back, with the soft sunset glow shining on your rosy cheek, I knew, I knew that I was already drunk on you. Then, after several months’ observation and prying, your grace and your wisdom, your attitude to life and your aspiration for future were all strongly impressed on my memory. You were the glamorous and sunny girl whom I always dream of to share the rest of my life with. Alas, actually you were far beyond my wildest dreams and I had no idea about how to bridge that gulf between you and me. So I schemed nothing but to wait, to wait for an appropriate opportunity. Till now — the arrival of graduation, I realize I am such an idiot that one should create the opportunity and seize it instead of just waiting.
These days, having parted with friends, roommates and classmates one after another, I still cannot believe the fact that after waving hands, these familiar faces will soon vanish from our life and become no more than a memory. I will move out from school tomorrow. And you are planning to fly far far away, to pursue your future and fulfill your dreams. Perhaps we will not meet each other any more if without fate and luck. So tonight, I was wandering around your dormitory building hoping to meet you there by chance. But contradictorily, your appearance must quicken my heartbeat and my clumsy tongue might be not able to belch out a word. I cannot remember how many times I have passed your dormitory building both in Zhuhai and Guangzhou, and each time aspired to see you appear in the balcony or your silhouette that cast on the window. I cannot remember how many times this idea comes to my mind: call her out to have dinner or at least a conversation. But each time, thinking of your excellence and my commonness, the predominance of timidity over courage drove me leave silently.
Graduation, means the end of life in university, the end of these glorious, romantic years. Your lovely smile which is my original incentive to work hard and this unrequited love will be both sealed as a memory in the deep of my heart and my mind. Graduation, also means a start of new life, a footprint on the way to bright prospect. I truly hope you will be happy everyday abroad and everything goes well. Meanwhile, I will try to get out from puerility and become more sophisticated. To pursue my own love and happiness here in reality will be my ideal I never desert.
Farewell, my princess!
If someday, somewhere, we have a chance to gather, even as gray-haired man and woman, at that time, I hope we can be good friends to share this memory proudly to relight the youthful and joyful emotions. If this chance never comes, I wish I were the stars in the sky and twinkling in your window, to bless you far away, as friends, to accompany you every night, sharing the sweet dreams or going through the nightmares together.
Here comes the problem: Assume the sky is a flat plane. All the stars lie on it with a location (x, y). for each star, there is a grade ranging from 1 to 100, representing its brightness, where 100 is the brightest and 1 is the weakest. The window is a rectangle whose edges are parallel to the x-axis or y-axis. Your task is to tell where I should put the window in order to maximize the sum of the brightness of the stars within the window. Note, the stars which are right on the edge of the window does not count. The window can be translated but rotation is not allowed.

Input

There are several test cases in the input. The first line of each case contains 3 integers: n, W, H, indicating the number of stars, the horizontal length and the vertical height of the rectangle-shaped window. Then n lines follow, with 3 integers each: x, y, c, telling the location (x, y) and the brightness of each star. No two stars are on the same point. There are at least 1 and at most 10000 stars in the sky. 1<=W,H<=1000000, 0<=x,y<2^31.

Output

For each test case, output the maximum brightness in a single line.

Sample Input

3 5 4
1 2 3
2 3 2
6 3 1
3 5 4
1 2 3
2 3 2
5 3 1

Sample Output

5
6

HINT

 

题意

给你一个w*h的矩形,和N个点,每个点都有一个权值,然后你用这个矩形去圈住他们,然后问你矩形所能圈住的最大权值是多少

题解:

 呀,把所有点都转化成矩形,然后就可以把这道题变成,找一个点,使的这个点所在的矩形的权值最大

然后就可以用扫描线搞一搞就好了

代码:

 

//qscqesze#include 
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
typedef long long ll;using namespace std;//freopen("D.in","r",stdin);//freopen("D.out","w",stdout);#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)#define maxn 50000#define mod 10007#define eps 1e-9//const int inf=0x7fffffff; //无限大const int inf=0x3f3f3f3f;/*int buf[10];inline void write(int i) { int p = 0;if(i == 0) p++; else while(i) {buf[p++] = i % 10;i /= 10;} for(int j = p-1; j >=0; j--) putchar('0' + buf[j]); printf("\n");}*///**************************************************************************************inline ll read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){ if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}#define LL(x) (x<<1)#define RR(x) (x<<1|1)#define MID(a,b) (a+((b-a)>>1))const int N=2000005;typedef long long LL;struct Line{ LL x,y1,y2,valu; Line(){} Line(LL a,LL b,LL c,LL d) { x=a;y1=b;y2=c;valu=d; } bool operator<(const Line&b)const { return x
y;vector
line;map
H;struct Segtree{ node tree[N*4]; void build(int lft,int rht,int ind) { tree[ind].lft=lft; tree[ind].rht=rht; tree[ind].mx=0; tree[ind].flag=0; if(lft+1!=rht) { int mid=tree[ind].mid(); build(lft,mid,LL(ind)); build(mid,rht,RR(ind)); } } void updata(int st,int ed,int ind,int valu) { int lft=tree[ind].lft,rht=tree[ind].rht; if(st<=lft&&rht<=ed) tree[ind].fun(valu); else { if(tree[ind].flag) { tree[LL(ind)].fun(tree[ind].flag); tree[RR(ind)].fun(tree[ind].flag); tree[ind].flag=0; } int mid=tree[ind].mid(); if(st
mid) updata(st,ed,RR(ind),valu); tree[ind].mx=max(tree[LL(ind)].mx,tree[RR(ind)].mx); } }}seg;int main(){ int n,w,h; while(scanf("%d%d%d",&n,&w,&h)!=EOF) { y.clear(); H.clear(); line.clear(); for(int i=0;i

 

转载地址:http://fwqlx.baihongyu.com/

你可能感兴趣的文章
C# 语言规范_版本5.0 (第4章 类型)
查看>>
入门级----黑盒测试、白盒测试、手工测试、自动化测试、探索性测试、单元测试、性能测试、数据库性能、压力测试、安全性测试、SQL注入、缓冲区溢出、环境测试...
查看>>
[1252]进制转换 sdutOJ
查看>>
composer 安装 ubuntu 12.04
查看>>
Vue开发与调试工具
查看>>
DES加密解密
查看>>
2017年1月15日,开始认真读书!!!
查看>>
oracle TNS-12549: TNS:operating system resource quota exceeded
查看>>
css背景图片位置:background的position(转)
查看>>
【总结整理】webstorm插件使用
查看>>
微服务(二)hystrix
查看>>
git for windows
查看>>
浅谈oracle中for update 和 for update nowait 和 for update wait x的区别
查看>>
DOS与内存
查看>>
[Micropython]发光二极管制作炫彩跑马灯
查看>>
jQuery获取Select选择的Text和 Value(转)
查看>>
C# System.IO.Path
查看>>
Virtualbox中的Linux:未能加载虚拟光驱 VBoxsGuestAdditions.iso到虚拟电脑
查看>>
Socket.io各个发送消息的含义【发送对象范围】
查看>>
Spark应用(app jar)发布到Hadoop集群的过程
查看>>