Stars in your window
测试数据来自 nnu_contest/1283
Stars in your window
时间限制:4s
空间限制:64MB
题目背景
由于原题背景较长,将放到题目结尾。
对题目背景的理解不影响做题。
题目描述
接下来问题来了。我们可以将天空看作一条数轴,在这条数轴上的\(1,2,...n\)位置各有一颗星星,其初始亮度\(b_i\),但随着时间的改变,某些星星的亮度也可能有所变化。 窗户的宽度是给定的数值\(w\),即窗户的左边界为\(a\)时,天空中位置为\( [a,a+w]\)的共计\(w+1\)颗星星都能被看见。 注意:窗户边缘的星星也能被看到 。
现在,你可以调整窗户的位置,使得能看见的星星的亮度总和最大。请输出亮度总和的最大值。
输入格式
第一行两个正整数\(n,w\),表示星星的数量和窗户的宽度。
接下来一个整数\(b_i\),表示各个星星的的亮度。
接下来一个正整数\(m\),表示对星星亮度的修改操作数量。
接下来\(m\)行每行两个整数\(x,y\),表示将第\(x\)颗星星的亮度修改为\(y\), 在每次修改后,请再次输出答案。
输出格式
\(m+1\)行,每行一个正整数,分别表示第\(0,1,2,...m\)次修改后的答案。
样例输入1
6 2
2 4 8 4 2 1
0
样例输出1
16
样例1解释
窗户至多包含三颗星星。连续的最大和应该是4+8+4 = 16
样例输入2
10 2
1 7 4 5 12 4 7 2 3 8
3
5 1
4 14
7 99
样例输出2
23
16
25
105
样例2解释
一开始星星亮度为\(1,7,4,5,12,4,7,2,3,8\)
所以答案是\(12+4+7=23\)
将第5颗星星的亮度改为\(1\),所以亮度为\(1,7,4,5,1,4,7,2,3,8\)
所以答案是\(7+4+5=16\)
将第4颗星星的亮度改为\(14\),所以亮度为\(1,7,4,14,1,4,7,2,3,8\)
所以答案是\(7+4+14=25\)
将第7颗星星的亮度改为\(99\),所以亮度为\(1,7,4,14,1,4,99,2,3,8\)
所以答案是\(105\)
数据范围及限制
共\(10\)组测试数据。对于前\(5\)个测试点,每个测试点\( 30\)分。对于其他测试点,每个测试点\(40\)分。
对于前\(10\%\)数据,\(w=0, n\le 10, m = 0\),因为\(w=0\),所以每次只能看到一颗星星。
对于前\(30\%\)数据,\(0\le w< n\le 10^2, m = 0\)
对于前\(50\%\)数据,\(0\le w< n\le 10^5, m = 0\), 即: 没有修改操作
对于\(100\%\)的数据,\(0\le w< n\le 10^5, 0\le m\le 5*10^5,1\le b_i\le 10^4\)
对于每一次修改操作\((x,y)\),都有 \(1\le x\le n, 1\le y\le 10^4\)
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: ......
(Description 来源于 POJ 2482, Author:kinfkong@ZSU,题面有改动)
信息
- ID
- 2884
- 难度
- (无)
- 分类
- (无)
- 标签
- (无)
- 递交数
- 0
- 已通过
- 0
- 通过率
- ?
- 上传者