Codeforces Round #835 (Div. 4) - D. Challenging Valleys
D. Challenging Valleys
枚举所有相等的连续段,判断符合条件的是否只有一段即可。
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i = a;i<n;i++)
#define per(i,a,n) for(int i = n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define yes cout<<"YES"<<'\n';
#define no cout<<"NO"<<'\n';
#define endl '\n';
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod=1000000007;
int rnd(int x) {return mrand() % x;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;};
ll lcm(int a,int b){return a*b/gcd(a,b);}const int N=2e5+10;
int T;
int n;
int a[N];void solve(){cin>>n;int cnt=0;rep(i,0,n) cin>>a[i];int l=0,r=0;while(l<n&&r<n){while(r<n-1&&a[r]==a[r+1]) r++;if((l==0||a[l-1]>a[l])&&(r==n-1||a[r]<a[r+1])){cnt++;}l=r+1,r=l;}puts(cnt==1?"YES":"NO");
}int main(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>T;while(T--){solve();}return 0;
}
Codeforces Round #835 (Div. 4) - D. Challenging Valleys相关推荐
- Codeforces Round #835 (Div. 4) B. Lost Permutation
You are given an array a[0-n−1]a[0-n−1] of nn integers. This array is called a "valley" if ...
- Codeforces Round #632 (Div. 2)巧用小技巧
Codeforces Round #632 (Div. 2)点这 Eugene likes working with arrays. And today he needs your help in s ...
- Codeforces Round #695(Div. 2)
Codeforces Round #695 (Div. 2) 1467A Wizard of Orz 1467B Hills And Valleys 1467C Three Bags 1467D Su ...
- Codeforces Round #506 (Div. 3)
Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...
- Codeforces Round #563 (Div. 2)/CF1174
Codeforces Round #563 (Div. 2)/CF1174 CF1174A Ehab Fails to Be Thanos 其实就是要\(\sum\limits_{i=1}^n a_i ...
- 构造 Codeforces Round #302 (Div. 2) B Sea and Islands
题目传送门 1 /* 2 题意:在n^n的海洋里是否有k块陆地 3 构造算法:按奇偶性来判断,k小于等于所有点数的一半,交叉输出L/S 4 输出完k个L后,之后全部输出S:) 5 5 10 的例子可以 ...
- Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解(每日训练 Day.16 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #696 (Div. 2) (A ~ E)超高质量题解 比赛链接:h ...
- Codeforces Round #712 Div.2(A ~ F) 超高质量题解(每日训练 Day.15 )
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 Codeforces Round #712 Div.2(A ~ F) 题解 比赛链接:https:// ...
- Codeforces Round #701 (Div. 2) A ~ F ,6题全,超高质量良心题解【每日亿题】2021/2/13
整理的算法模板合集: ACM模板 点我看算法全家桶系列!!! 实际上是一个全新的精炼模板整合计划 目录 A - Add and Divide B - Replace and Keep Sorted C ...
最新文章
- 企业官网建设搞清三个定位
- 获取当天日期、昨天日期
- 商品订单表怎么设计_三级分销系统系统设计
- html5 cs js字母验证码,JavaScript生成图形验证码
- python opencv 录制视频_python - 使用Opencv Python多线程录制视频 - 堆栈内存溢出
- mysql merge事务_mysql菜鸟手迹11--mysql存储引擎之Merge
- Python量化交易基础讲堂-详解随机数的生成
- C/C++怎样传递二维数组,转载自CSDN
- plsql创建、测试存储过程
- @RequestMapping、@GetMapping、@PostMapping、@PutMapping、@DeleteMapping、@PatchMapping详解
- websphere7 mysql_websphere7
- iOS 图片模糊效果(高斯模糊)
- 计算机单招基础知识试题,高职单招《计算机类专业基础知识》正式试卷
- 用python画玫瑰花
- 我参加第七届NVIDIA Sky Hackathon——训练CV模型
- Linux系统病毒防治
- STM32F103C8T6驱动SYN6288语音模块(暂时做到能播放连续语音,其他诸如背景音乐的功能还没做)
- VM_02_linux常用命令及操作
- MATLAB三维数组转为二维数组(时间序列分析中很有用)
- 那些日子 我们曾走过