Codeforces Round #616 (Div. 2) B. Array Sharpening
t题目链接:http://codeforces.com/contest/1291/problem/B
思路:
用极端的情况去考虑问题,会变得很简单。
无论是单调递增,单调递减,或者中间高两边低的情况都可以变为三种模型。
(1)0,1,2,3,4........n-3,n-2,n-1
(2)n-1,n-2,n-3.....3,2,1,0
(3)0,1,2,3,4,.....n.......4,3,2,1,0
那么,我们只需要查看当前位置是否大于等于极端模型(3)在这个位置的数值,如果当前位置不满足了,
那么我们就让当前位置和之后的数值去和极端模型(3)n后面递减的数值去比较,如果还有不满足的情况说明就是“NO”了。
注意一种情况 0 1 1 0需要特殊处理一下。
#include <iostream>
using namespace std; const int N = (int)3e5+;
int a[N]; int main(){ int T,n;
while(cin >> T){
while(T--){
cin >> n;
for(int i = ; i <= n; ++i) cin >> a[i];
int i;
bool ok = ;
//递增区间判断
for(i = ; i <= n; ++i){
if(a[i] >= i-) continue;
break;
}
// 0 1 1 0 这种情况判定
if(i <= n){
if(a[i] == a[i-] && !(a[i] >= n-i+)) ok = ;
}
//递减区间判定
for(; i <= n; ++i){
if(a[i] >= n-i) continue;
ok = ; break;
}
//if(ok) cout << "----------Yes" << endl;
//else cout << "----------No" << endl;
if(ok) cout << "----------Yes" << endl;
else cout << "----------No" << endl;
}
} }
Codeforces Round #616 (Div. 2) B. Array Sharpening的更多相关文章
- Codeforces Round #616 (Div. 2) 题解
A. Even But Not Even 题意: 定义一个数所有位置的和为偶数它本身不为偶数的数为ebne,现在给你一个数字字符串,你可以删除任意位置上的数字使其变为ebne输出任意改变后的结果,如果 ...
- Codeforces Round #181 (Div. 2) A. Array 构造
A. Array 题目连接: http://www.codeforces.com/contest/300/problem/A Description Vitaly has an array of n ...
- Codeforces Round #284 (Div. 1) C. Array and Operations 二分图最大匹配
题目链接: http://codeforces.com/problemset/problem/498/C C. Array and Operations time limit per test1 se ...
- Codeforces Round #535 (Div. 3) E2. Array and Segments (Hard version) 【区间更新 线段树】
传送门:http://codeforces.com/contest/1108/problem/E2 E2. Array and Segments (Hard version) time limit p ...
- Codeforces Round #616 (Div. 2) C. Mind Control
题目链接:http://codeforces.com/contest/1291/problem/C 思路: 我们可以很容易想到,只有前m-1个人才能影响m的选择的大小,后面的人无法影响. 如果所有人都 ...
- Codeforces Round #617 (Div. 3)A. Array with Odd Sum(水题)
You are given an array aa consisting of nn integers. In one move, you can choose two indices 1≤i,j≤n ...
- Codeforces Round #616 (Div. 2)
地址:http://codeforces.com/contest/1291 A题就不写解析了,就是给一个数,是不是本身满足这个条件或者删除某些数字来达到这个条件:奇数,各个位上的数字加起来是偶数. # ...
- Codeforces Round #284 (Div. 1) C. Array and Operations 二分图匹配
因为只有奇偶之间有操作, 可以看出是二分图, 然后拆质因子, 二分图最大匹配求答案就好啦. #include<bits/stdc++.h> #define LL long long #de ...
- Codeforces Round #510 (Div. 2) C. Array Product
题目 题意: 给你n个数,有两种操作,操作1是把第i个位置的数删去, 操作2 是把 a[ j ]= a[ i ]* a[ j ],把a[ i ]删去 .n-1个操作以后,只剩1个数,要使这个数最大 . ...
随机推荐
- 杭电-------2032杨辉三角(C语言写)
#include<stdio.h> ][] = { }; void init() { int i, j; ; i < ; i++) { a[i][] = ; a[i][i] = ; ...
- .NET Core 3 Web Api Cors fetch 一直 307 Temporary Redirect
.NET Core 3 Web Api Cors fetch 一直 307 Temporary Redirect 继上一篇 .net core 3 web api jwt 一直 401 为添加JWT- ...
- 网页延迟加载动画的实现-WOW.js
网页内容一开始不显示,随着鼠标下拉延迟显示,还有时间差 一开始觉得好难好复杂好高大上,直到我发现 wow.js …… 首先是演示地址:https://www.delac.io/wow/ 嗯,狗子确实很 ...
- Android中调用另一个Activity并返回结果-以模拟选择头像功能为例
场景 Android中点击按钮启动另一个Activity以及Activity之间传值: https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/detail ...
- 学习 Vim 命令总结
学习 Vim 命令总结 可以使用 vscode-vim 扩展,但是要注意一些ctrl+字母的快捷键会无效,必须去掉冲突的快捷键 esc 回到普通模式 i 普通模式进入插入模式 : 进入命令模式 :wa ...
- Html介绍,了解html代码的注释
什么是代码注释?在代码编辑器中的注释代码是不会在浏览器窗口展示的!html代码注释的作用是帮助程序员标注代码的用途,过一段时间后再看你之前编写的代码,很快可以想起这个代码的用途.代码注释不仅方便程序员 ...
- 使用Arduino Nano驱动Lora模块
使用Arduino Nano驱动Lora模块 为什么选用Lora 射频通信芯片有很多种,但是一般在同样功耗下,距离没有Lora远;同等范围下,没有Lora节能. Lora通信只适用于低速率,高延时的场 ...
- 离散对数及其拓展 大步小步算法 BSGS
离散对数及其拓展 离散对数是在群Zp∗Z_{p}^{*}Zp∗而言的,其中ppp是素数.即在在群Zp∗Z_{p}^{*}Zp∗内,aaa是生成元,求关于xxx的方程ax=ba^x=bax=b的解, ...
- opencv —— src.at<Vec3b>(i, j)[0]、src.at<uchar>(i, j)、src.ptr<uchar>(i) 访问图像的单个像素
动态地址访问像素:src.at<Vec3b>(i, j)[0].src.at<uchar>(i, j) int b = src.at<Vec3b>(i, j)[0 ...
- vscode侧边栏字体大小修改
1.找到安装路径下,workbench.desktop.main.css 文件 C:\z_my_install\Microsoft VS Code\resources\app\out\vs\workb ...