![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
前缀和
libulala
算法练习
展开
-
Number of Ways
Number of WaysYou’ve got array a[1], a[2], …, a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same.More formally, you need to find原创 2021-02-07 02:29:05 · 170 阅读 · 0 评论 -
Segment Occurrences
Segment OccurrencesYou are given two strings s and t, both consisting only of lowercase Latin letters.The substring s[l…r] is the string which is obtained by taking characters sl,sl+1,…,sr without changing the order.Each of the occurrences of string a i原创 2021-02-07 02:21:37 · 141 阅读 · 0 评论 -
前缀极差
前缀极差蒜头君有 n 个数,他提出了 q 个问题,每个问题是说,询问前 x 个数的极差(最大值减最小值)。你能帮助他解决这 q 个问题吗?输入格式第一行两个整数 n,q(1≤n,q≤105)第二行 n个整数 ai(1≤ai≤109)表示蒜头君的 n个数第三行 q个整数 xi(1≤xi≤n),表示每一次询问输出格式输出一行,包含 q个整数,表示每一次询问的答案数据范围对于 60%的数据, 1≤n,q≤103对于 100%的数据,1≤n,q≤105Sample Input5 53 2 4原创 2021-02-07 02:15:37 · 1145 阅读 · 4 评论 -
最大的和
最大的和给定一个包含整数的二维矩阵,子矩形是位于整个阵列内的任何大小为1 * 1或更大的连续子阵列。矩形的总和是该矩形中所有元素的总和。在这个问题中,具有最大和的子矩形被称为最大子矩形。例如,下列数组:0 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2其最大子矩形为:9 2-4 1-1 8它拥有最大和15。输入格式输入中将包含一个N*N的整数数组。第一行只输入一个整数N,表示方形二维数组的大小。从第二行开始,输入由空格和换行符隔开的N2个整数,它们即为二原创 2021-01-31 17:05:26 · 185 阅读 · 0 评论