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个数,要使这个数最大 . ...
随机推荐
- 杭电-------2046骨牌铺方格(C语言写)
#include<stdio.h> ] = { }; long long recrusion(int n) { || a[n]>) { return a[n]; } ) + recr ...
- 记录KVM虚拟机常用操作管理命令
环境说明 centos7中的KVM NAT方式是kvm安装后的默认方式.它支持主机与虚拟机的互访,同时也支持虚拟机访问互联网,但不支持外界访问虚拟机. 检查当前的网络设置 # virsh net-li ...
- oracle表空间位置迁移
1.先登录sqlplus: C:\Documents and Settings\jbdu>sqlplus “/as sysdba”2.修改表空间为Offline: SQL> alter t ...
- js—DOM详情
1,什么是DOM,有什么作用 Document Object Model 文档对象模型,是一个html和xml文档的编程接口,可以将文档(html页面)解析成dom树,然后通过提供的dom接口来改变文 ...
- 获取域hash并破解
ntds.dit ntds.dit是主要的AD数据库,存放在C:\Windows\NTDS\NTDS.dit,包括有关域用户,组和组成员身份的信息.它还包括域中所有用户的密码哈希值.为了进一步保护密码 ...
- python練習
#登录,账户密码储存在文件中,限制登录 count = 0 for i in range(3): b = input("账号:") c = b + "," + ...
- python函数的使用
python函数的使用 制作人:全心全意 函数的定义 def 函数名(参数): 函数体 参数的使用 def 函数名(a): 函数体 函数名(5) 默认函数 def 函数名(a=5): 函数体 函数名( ...
- 基于axios的万能封装
一 . 命名axios.js import axios from 'axios'; export default function ajax(url = '', params = {}, type = ...
- 【MVC+EasyUI实例】对数据网格的增删改查(上)
前言 此案例是针对之前做的一个小例子的后台框架的修改,从以前的三层框架改为现在的MVC框架,也是做了一次MVC和EasyUI的结合,分为2篇文章来阐述. 界面如下: 点击"添加"按 ...
- 00 - PXE | 环境准备
00 - PXE | 环境准备 TFTP PXE 1. TFTP服务搭建 安装环境Centos7.3 1.1 安装 # yum install xinetd # yum install tftp # ...