【题目链接】

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. SQL server高级语法

    1. 公共表达式CTE 公用表表达式 (CTE) 具有一个重要的优点,那就是能够引用其自身,从而创建递归 CTE.递归 CTE 是一个重复执行初始 CTE 以返回数据子集直到获取完整结果集的公用表表达 ...

  2. CNN:Windows下编译使用Caffe和Caffe2

    用于检测的CNN分为基于回归网络的方法和基于区域+CNN网络的方法,其中基于回归网络的方法典型为YOLO9000,可以兼容使用VGG-Net框架.其中基于区域+CNN网络方法,大量使用了Caffe作为 ...

  3. webapi部署到IIS 404错误

    环境:win2008r2+IIS 解决方案: 添加一个映射 可执行文件地址(根据系统决定64位可32位): C:\Windows\Microsoft.NET\Framework64\v4.0.3031 ...

  4. h5调用app中写好的的方法

    做h5页面的时候,总会遇到些不能解决的问题于是就要与app做一些交互, app那边编辑好的方法后我们怎么用js语法去调用app编写好的方法 if(this.$winInfo.shebei == 1){ ...

  5. style 使用lang = ‘scss’ 报错

    <style lang="scss" rel="stylesheet/scss" scoped> .export-wrapper{ } </s ...

  6. 【转】在VMware中为Linux系统安装VM-Tools的详解教程

    在VMware中为Linux系统安装VM-Tools的详解教程 如果大家打算在VMware虚拟机中安装Linux的话,那么在完成Linux的安装后,如果没有安装Vm-Tools的话,一部分功能将得不到 ...

  7. 解决postman https请求无返回数据的问题

    1.点击右上角的扳手图标 2.点击settings 3.点击general 4.把 ssl certificate verification这项点击关闭

  8. 前端开发—HTML

    HTML介绍 web服务的本质 import socket sk = socket.socket() sk.bind(("127.0.0.1", 8080)) sk.listen( ...

  9. [MySQL优化案例]系列 — 分页优化

    通常,我们会采用ORDER BY LIMIT start, offset 的方式来进行分页查询.例如下面这个SQL: SELECT * FROM `t1` WHERE ftype=1 ORDER BY ...

  10. [luogu 4886] 快递员

    传送门 Solution 虽然不是点分治但用类似点分治的方法不断接近正确结果 Code // luogu-judger-enable-o2 #include <cstdio> #inclu ...