正题 题目链接:https://www.luogu.com.cn/problem/P7294 题目大意 \(n\times m\)的网格,当你在\((x,y)\)时你有两种选择 花费\(x^2\)的代价向右移动 花费\(c_y\)的代价向下移动 \(q\)次询问\((1,1)\)走到\((x,y)\)的最小代价. \(1\leq n\leq 10^9,1\leq m,q\leq 2\times 10^5\) 解题思路 假设我们开始都是直接走最上面向右的路(也就是代价都是\(1^2\)). 然后考…
鉴于早上那题让我怀疑单调栈白学,特意来复习下单调栈 题意 考虑按照每个元素对答案的贡献来统计,那么我们只需要找到每个元素左边右边第一个比它小的就可 这题给的又是排列,简直不能再良心 #include <bits/stdc++.h> using namespace std; #define int long long const int N = 1000005; int s[N],top,a[N],l[N],r[N],n,ans; signed main() { cin>>n; fo…
Mike and Feet Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 548D Appoint description:  Description Mike is the president of country What-The-Fatherland. There are n bears living in thi…
单调栈: 维护一个单调栈 A Famous City Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1671    Accepted Submission(s): 644 Problem Description After Mr. B arrived in Warsaw, he was shocked by the skyscrap…
Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standing in a line and they are numbered from 1 to n from left to right. i-th bear is exactly ai feet high. A group of bears…
You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the difference between the maximum and minimum element from this segment. The imbalance value of the array is the sum of imbalance valuesof all…
D. Imbalanced Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You are given an array a consisting of n elements. The imbalance value of some subsegment of this array is the differenc…
[CF671E]Organizing a Race 题意:n个城市排成一排,每个城市内都有一个加油站,赛车每次经过第i个城市时都会获得$g_i$升油.相邻两个城市之间由道路连接,第i个城市和第i+1个城市之间的道路长度为$w_i$,走一单位的路要花1升油.你想在某两个城市之间举办一场锦标赛.如果你选择的两个城市分别是a和b(a<b),则具体过程如下: 1. 赛车从a开始往右走一直走到b,走过城市时会在加油站加油,走过道路时会消耗油,且一开始时就已经在a处加完油了.你需要满足赛车能有足够的油能从a…
题目链接:点击传送 MINSUB - Largest Submatrix no tags  You are given an matrix M (consisting of nonnegative integers) and an integer K.  For any submatrix of M' of M define min(M') to be the minimum value of all the entries of M'.  Now your task is simple:  f…
B. Mike and Feet Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B Description Mike is the president of country What-The-Fatherland. There are n bears living in this country besides Mike. All of them are standi…