ACM: 线段树 poj 2750 连续最大和
来源:互联网 发布:mac安装jdk 编辑:程序博客网 时间:2024/06/05 10:08
(Positions of potted flowers are assigned to index numbers in therange of 1 ... N. The i-th pot and the (i + 1)-th pot areconsecutive for any given i (1 <= i <N), and 1st pot is next to N-th pot in addition.)
The board chairman informed the little cat to construct "ONEarc-style cane-chair" for tourists having a rest, and the sum ofattractive values of the flowers beside the cane-chair should be aslarge as possible. You should notice that a cane-chair cannot be atotal circle, so the number of flowers beside the cane-chair may be1, 2, ..., N - 1, but cannot be N. In the above example, if weconstruct a cane-chair in the position of that red-dashed-arc, wewill have the sum of 3+(-2)+1+2=4, which is the largest among allpossible constructions.
Unluckily, some booted cats always make trouble for the little cat,by changing some potted flowers to others. The intelligence agencyof little cat has caught up all the M instruments of booted cats'action. Each instrument is in the form of "A B", which meanschanging the A-th potted flowered with a new one whose attractivevalue equals to B. You have to report the new "maximal sum" aftereach instruction.
Input
The second line contains N integers, which are the initialattractive value of each potted flower. The i-th number is for thepotted flower on the i-th position.
A single integer M (4 <= M <= 100000)in the third input line, and the following M lines each contains aninstruction "A B" in the form described above.
Restriction: All the attractive values are within [-1000, 1000]. Weguarantee the maximal sum will be always a positiveinteger.
Output
Sample Input
5
3 -2 1 2 -5
4
2 -2
5 -5
2 -4
5 -1
Sample Output
4
4
3
5
题意: Little cat 要布置一个circle形状的花卉, 圆形的花卉由每一个pot构成,并且每一个pot有一个
解题思路:
代码:
#include<cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX 100005
struct node
{
}pt[MAX*4];
int n, m;
int a[MAX];
int A, B;
inline int max(int a, int b)
{
}
inline int min(int a, int b)
{
}
inline void change1(int pos, int val)
{
}
inline void change2(int pos)
{
}
void buildTree(int l, int r, int pos)
{
}
void insert(int A, int B, int pos)
{
}
int main()
{
//
}
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 2352
- ACM: 线段树 poj 1177
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 3264
- ACM: 线段树 poj 3368
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 1151 足足想了三…
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2482 煽情的情书!…
- poj 3321 Apple Tree 线段树
- poj 2182 Lost Cows 线段树
- 【线段树】 POJ 2828 Buy Tickets
- ACM: 最大连续和O(N) 动态规划 toj…
- POj 2379 ACM Rank Table
- ACM: trie树 poj 2513
- ACM: 线段树 poj 2528 离散化即可
- ACM: 线段树 poj 2828 认真对待每…
- ACM: 线段树 poj 2777 继续熟练线…
- ACM: 线段树 poj 2886 约瑟夫问题
- ACM: 线段树 poj 2750 连续最大和
- ACM: 线段树 poj 3468
- ACM: 线段树 poj 3277
- ACM: 线段树 poj 2482 煽情的情书!…
- C++ 友元类
- ACM: 树状数组 poj 1195
- ACM: 树状数组 poj 2155 学习《浅…
- ACM: 树状数组 poj 3321 图论+树状…
- spring配置出错at org.hibernate.engine.jdbc.internal.JdbcServicesImpl.configure(JdbcServicesImpl.java:244