您当前的位置: 首页 > 

*DDL_GzmBlog

暂无认证

  • 0浏览

    0关注

    605博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

[补题|题解] B - Hills And Valleys

*DDL_GzmBlog 发布时间:2021-09-26 16:48:47 ,浏览量:0

前言

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            
关注
打赏
1657615554
查看更多评论
0.0397s