Stars in Your Window

Stars in Your Window

问题描述:

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

翻译

描述

闪光的时间不会模糊我对你的记忆。从我第一次见到你以来,它真的可以4年吗?我还记得,生动地,在美丽的珠海校园,4年前,从我看到你微笑的那一刻,当你走出教室,把你的头转向你的柔和的夕阳辉光照耀着你的玫瑰色的脸颊,我知道,我知道我已经喝醉了你。然后,经过几个月的观察和窥探,你的恩典和你的智慧,你的生活态度和你对未来的愿望都深深地印象了我的记忆。你是我永远梦想的魅力和阳光女孩与我分享我的余生。唉,实际上你远远超出了我最疯狂的梦想,我不知道如何桥接你和我之间的海湾。所以我只想等待,等待一个适当的机会。直到现在 - 毕业的到来,我意识到我是一个白痴,应该创造机会,抓住它,而不是只是等待。

这些日子,我已经和朋友,室友和同学一个接一个地离开,我仍然不能相信,在挥手之后,这些熟悉的面孔很快就会从我们的生活中消失,变成只是一个记忆。我明天会离开学校。你计划飞得很远,追求你的未来,实现你的梦想。也许我们不会相遇,如果没有命运和运气。所以今晚,我正在徘徊在你的宿舍楼,希望偶然遇见你。但是矛盾的是,你的外表必须加快我的心跳,我的笨拙的舌头可能不能煽起一个字。我不记得有多少次我已经通过了在珠海和广州的宿舍楼,每次都希望看到你出现在阳台上或你的轮廓在窗户上。我不记得这个想法有多少次到我的脑海:打电话给她吃晚饭或至少一个谈话。但每次,考虑到你的卓越和我的共同之处,胆怯的勇气超越勇气驱使我静静地离开。

毕业,意味着大学的生命的终结,这些光荣,浪漫的时代的结束。你可爱的微笑,这是我原来的努力工作的努力和这种无聊的爱会被密封作为一个记忆在我深深的心和我的心灵。毕业,也意味着新生活的开始,一个到达光明前景的足迹。我真的希望你会在国外的日常生活愉快,一切顺利。与此同时,我将努力从繁荣中走出来,变得更加复杂。追求我自己的爱和幸福在这里的现实将是我的理想,我从来没有沙漠。

告别,我的公主!

如果有一天,某个地方,我们有机会聚集,即使是灰白的男人和女人,在那个时候,我希望我们可以成为好朋友,分享这个记忆自豪地重新抚慰年轻和快乐的情绪。如果这个机会没有到来,我希望我是在天空中的星星,在你的窗口闪烁,作为朋友向你保佑你,每天晚上陪伴你,分享甜蜜的梦想或通过噩梦在一起。

这里来的问题:假设天空是一个平面。所有的星都躺在它的位置(x,y)。对于每个星,存在从1到100的等级,代表其亮度,其中100是最亮的,1是最弱的。窗口是其边缘平行于x轴或y轴的矩形。你的任务是告诉我应该把窗口放在哪里,以便最大化窗口内星星亮度的总和。注意,在窗口边缘的星星不计算在内。窗口可以平移,但不允许旋转。
输入

在输入中有几个测试用例。每种情况的第一行包含3个整数:n,W,H,表示星形的数量,矩形窗口的水平长度和垂直高度。然后n行跟随,每个有3个整数:x,y,c,告诉位置(x,y)和每个星的亮度。没有两颗星在同一点上。

在天空中至少有1颗星和最多10000颗星。 1 <= W,H <= 1000000,0 <= x,y <2 ^ 31。
输出

对于每个测试用例,在一行中输出最大亮度。
样品输入

3 5 4
1 2 3
2 3 2
6 3 1
3 5 4
1 2 3
2 3 2
5 3 1
示例输出

5
6