前言
B - Hills And Valleys
思路借鉴: https://blog.csdn.net/jziwjxjd/article/details/112388715 传送门 : https://codeforces.com/contest/1467/problem/B
思路因为数据范围 O (t*n) 正好是1e9可以跑一遍O n算法
(我心想着怎么优化呢 怎么题目这么难 没想到题目这么简单)
因为只是修改一个数 abc中的b 所以我们直接枚举所有b的改变情况 比较一下即可
总体上感觉是贪心
我总是心有余悸 感觉会影响旁边的那两个
CODE#include
using namespace std;
const int maxn = 3e5+10;
using ll = long long;
int t ,n,a[maxn];
bool check(int i)
{
if(i>=2 && ia[i+1] && a[i]>a[i-1])return true;
if(a[i]n;
for(int i=1;i>a[i];
int ans =0 ,t =0 ;
for(int i=2;i
关注
打赏