Something About Me
Who am I ?
B.E. in Computer Science and Technology
@ University of Science and Technology of China
September 2022 - June 2026 @ Anhui, Chinas
B.E. in Computer Science and Technology
@ University of Science and Technology of China
September 2022 - June 2026 @ Anhui, Chinas
写在前面:该题转载至codeforces Codeforces Round 981 (Div. 3)😃
time limit per test2 seconds
memory limit per test256 megabytes
After a trip with Sakurako, Kousuke was very scared because he forgot about his programming assignment. In this assignment, the teacher gave him an array a of n integers and asked him to calculate the number of non-overlapping segments of the array a, such that each segment is considered beautiful.
A segment [l,r] is considered beautiful if al+al+1+⋯+ar−1+ar=0.
For a fixed array a, your task is to compute the maximum number of non-overlapping beautiful segments.
写在前面:该题转载至leetcode力扣 No.871–最低加油次数 😃
汽车从起点出发驶向目的地,该目的地位于出发位置东面 target英里处。
沿途有加油站,用数组 stations表示。其中 stations[i] = [positioni, fueli] 表示第 i 个加油站位于出发位置东面 positioni 英里处,并且有 fueli 升汽油。
假设汽车油箱的容量是无限的,其中最初有 startFuel 升燃料。它每行驶 1 英里就会用掉 1 升汽油。当汽车到达加油站时,它可能停下来加油,将所有汽油从加油站转移到汽车中。
为了到达目的地,汽车所必要的最低加油次数是多少?如果无法到达目的地,则返回 -1 。
注意:如果汽车到达加油站时剩余燃料为 0,它仍然可以在那里加油。如果汽车到达目的地时剩余燃料为 0,仍然认为它已经到达目的地。
输入:target =
1
, startFuel =1
, stations =[]
输出:0
解释:可以在不加油的情况下到达目的地。
写在前面:该题转载至leetcode力扣 No.42–接雨水 😃
给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。
输入:
height = [0,1,0,2,1,0,1,3,2,1,2,1]
输出:6
解释:上面是由数组[0,1,0,2,1,0,1,3,2,1,2,1]
表示的高度图,在这种情况下,可以接6
个单位的雨水(蓝色部分表示雨水)。