【题目链接】

http://codeforces.com/contest/451/problem/B

【算法】

模拟

在序列中找到一段单调递增的子序列,将这段序列反转,然后判断序列是否变得单调递增,即可

【代码】

#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + ; int i,n,l,r;
bool flag;
int a[MAXN]; int main()
{ scanf("%d",&n);
for (i = ; i <= n; i++) scanf("%d",&a[i]);
l = r = ;
flag = false;
for (i = ; i <= n; i++)
{
if (a[i] < a[i-])
{
if (!flag)
{
l = i - ;
r = i;
}
else r++;
flag = true;
} else if (flag) break;
}
reverse(a+l,a+r+);
for (i = ; i <= n; i++)
{
if (a[i] < a[i-])
{
printf("no\n");
return ;
}
}
printf("yes\n");
printf("%d %d\n",l,r); return ; }

【Codeforces 258B】 Sort the Array的更多相关文章

  1. 【24.17%】【codeforces 721D】Maxim and Array

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【codeforces 754A】Lesha and array splitting

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 719E】Sasha and Array

    [题目链接]:http://codeforces.com/contest/719/problem/E [题意] 给你一个数列,有两种操作1 l r x 给[l,r]区间上的数加上x, 2 l r 询问 ...

  4. 【Codeforces 1114B】Yet Another Array Partitioning Task

    [链接] 我是链接,点我呀:) [题意] 让你把数组分成k个连续的部分 使得每个部分最大的m个数字的和最大 [题解] 把原数组降序排序 然后选取前m*k个数字打标记 然后对于原数组 一直贪心地取 直到 ...

  5. 【44.19%】【codeforces 727C】Guess the Array

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  6. 【Codeforces 1042D】Petya and Array

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 把a[i]处理成前缀和 离散化. 枚举i从1..n假设a[i]是区间和的a[r] 显然我们需要找到a[r]-a[l]<t的l的个数 即a ...

  7. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  8. 【36.86%】【codeforces 558B】Amr and The Large Array

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  9. 【codeforces 797E】Array Queries

    [题目链接]:http://codeforces.com/problemset/problem/797/E [题意] 给你一个n个元素的数组; 每个元素都在1..n之间; 然后给你q个询问; 每个询问 ...

随机推荐

  1. Unity引擎的Player Settings介绍

    我用的是unity5.4.3版本的 一.窗口打开: 从菜单栏查看播放器设置,选择 Edit->Project Settings->Player 二.全局设置 第一部分: Company N ...

  2. list用法(用到了再补充)

    之前学list吧,也知道很多,但是到用的时候却无从下手,还是不熟悉的缘故,看来基础知识应该再加强,要达到信手拈来的程度才行. 先说下list的特性:有序可重复,也可以存储多个空值. 我用到的方法: L ...

  3. VMWare虚拟机Centos 6.9中的 linux 配置静态ip地址上外网

    1.查看网络 # ifconfig 发现网络还没有配置,ping不通 2.修改网卡配置文件 # vim /etc/sysconfig/network-scripts/ifcfg-eth0 添加如下配置 ...

  4. 从Hive1.0升级到Hive2.0(删除hive1.x中的元数据, 并不是数据迁移)

    软件环境: linux系统: CentOS6.7 Hadoop版本: 2.6.5 zookeeper版本: 3.4.8 主机配置: 一共m1, m2, m3这五部机, 每部主机的用户名都为centos ...

  5. Python 之 %s字符串、%d整型、%f浮点型

    %s string="hello" #%s打印时结果是hello print "string=%s" % string # output: string=hel ...

  6. [转]常用Git命令清单

    原文地址:http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html 作者: 阮一峰 日期: 2015年12月 9日 我每天使用 Git , ...

  7. asp.net mvc 学习步骤

    入门篇(一) ASP.NET MVC案例教程(基于ASP.NET MVC beta) http://www.cnblogs.com/leoo2sk/archive/2008/10/27/1320285 ...

  8. CorelDRAW记事本写实图标的制作流程

    本篇教程用CorelDRAW快速制作记事本写实图标,在制作的过程中主要使用了位图填充和金属材质的实现,加之一些常用工具的用法处理,最后将对象剪裁至图文框就好了,现在跟小编一起来看看详细的操作吧! 使用 ...

  9. apicloud UISearchBar 使用方法

    app中经常会有搜索的页面. 大概逻辑是,一般来说首页有一个搜索的图,点击之后跳转到一个搜索的页面,在这个页面做搜索. 正常代码逻辑 <body> <a class="bu ...

  10. NW.js构建PC收银端安装程序的指南

    1.首先下载nw.js的SDK: https://nwjs.org.cn/download.html 2.SDK目录下新建myapp文件夹: 3.myapp文件夹内新建package.json文件: ...