Can you answer these queries(spoj 1043)】的更多相关文章

题意:多次查询区间最长连续字段和 /* 用线段树维护区间最长子段和,最长左子段和,最长右子段和. */ #include<cstdio> #include<iostream> #define N 50010 using namespace std; ],lsum[N*],rsum[N*],n,m; void push_up(int k,int l,int r){ ; lsum[k]=max(lsum[k*],s[mid]-s[l-]+lsum[k*+]); rsum[k]=max(…
A lot of battleships of evil are arranged in a line before the battle. Our commander decides to use our secret weapon to eliminate the battleships. Each of the battleships can be marked a value of endurance. For every attack of our secret weapon, it…
有一列数,(都是2^63范围内的并且都大于0的整数),现在呢有一些操作, 操作 0 可以把区间LR内的所有数都变成它的平方根数(是取整后的),操作 1 可以就是求区间LR内的和了. 分析:因为这个操作是把一个数变成平方根,所以显得略棘手,不过如果仔细演算的话会发现一个2^64数的平方根开8次也就变成了 1,所以也更新不了多少次,所以可以每次更新到底.. 注意:给的X Y大小未知,会出现X > Y的情况 ***********************************************…
给定一个长度为n的序列,m次操作. 每次操作 可以将一个区间内的所有数字变为它的根号. 可以查询一个区间内所有元素的和. 线段树的初级应用. 如果把一个区间内的元素都改为它的根号的话,是需要每个数字都进行修改的.这样就会超时. 一个优化就是区间修改的当区间时,若区间长度等于区间和,那这个区间里的所有元素都不用修改了. 而题目中区间里的元素之和最大是 2^63,时间完全够用. #include <iostream> #include <cstdlib> #include <cs…
Can you answer these queries? Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65768/65768 K (Java/Others) Total Submission(s): 16260    Accepted Submission(s): 3809 Problem Description A lot of battleships of evil are arranged in a line befor…
F. String Set Queries time limit per test:3 seconds memory limit per test:768 megabytes input:standard input output:standard output You should process m queries over a set D of strings. Each query is one of three kinds: Add a string s to the set D. I…
Save the Students Time Limit:134MS     Memory Limit:0KB     64bit IO Format:%lld & %llu   Description Hogwarts is under attack by the Dark Lord, He-Who-Must-Not-Be-Named. To protect the students, Harry Potter must cast protective spells so that those…
You are given a sequence A[1], A[2], ..., A[N] . ( |A[i]| ≤ 15007 , 1 ≤ N ≤ 50000 ). A query is defined as follows: Query(x,y) = Max { a[i]+a[i+1]+...+a[j] ; x ≤ i ≤ j ≤ y }. Given M queries, your program must output the results of these queries. Inp…
recursion有一个整数序列a[n].现在recursion有m次询问,每次她想知道Max { A[i]+A[i+1]+...+A[j] ; x1 <= i <= y1 , x2 <= j <= y2 , x1 <= x2 , y1 <= y2 }.这么简单的题,recursion当然会做啦,但是为了维持她的傲娇属性,她决定考考你. Input 输入的第一行为数据组数.对于每组数据,第一行包含一个正整数n和长度为n的序列a[n].接下来一行有一个正整数m.下面m行分…
题目链接 题意 : 给你N个数,进行M次操作,0操作是将区间内的每一个数变成自己的平方根(整数),1操作是求区间和. 思路 :单点更新,区间查询,就是要注意在更新的时候要优化,要不然会超时,因为所有的数开几次方之后都会变成1,所以到了1不用没完没了的更新. //HDU 4027 #include <cstdio> #include <cstring> #include <cmath> #include <iostream> #define LL __int6…