题目

题意:

简而言之就是输出从最后开始遍历的递增到递减的符合这样条件的开头的下标(从右往左数)。

思路:

我们从最后开始遍历,然后先递增的遍历,然后再递减,最后结束的下标就是答案了。

#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <deque>
#include <stack>
#include <cctype>
using namespace std;
typedef long long ll;
typedef vector<int> veci;
typedef vector<ll> vecl;
typedef pair<int, int> pii;
template <class T>
inline void read(T &ret) {char c;int sgn;if (c = getchar(), c == EOF) return ;while (c != '-' && (c < '0' || c > '9')) c = getchar();sgn = (c == '-') ? -1:1;ret = (c == '-') ? 0:(c - '0');while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');ret *= sgn;return ;
}
int xxxxxxxxx = 1;
inline void outi(int x) {if (x > 9) outi(x / 10);putchar(x % 10 + '0');}
inline void outl(ll x) {if (x > 9) outl(x / 10);putchar(x % 10 + '0');}
inline void debug(ll x) {cout << xxxxxxxxx++ << " " << x << endl;}
inline void debugs(string s) {cout << s << endl;}
const int maxn = 2e5 + 10;
int a[maxn];
int main() {int t; read(t); while (t--) {int n; read(n); for (int i = 1; i <= n; i++) read(a[i]);int k = n;for (int i = n - 1; i >= 1; i--) {if (a[i] >= a[i + 1]) k--;else break;}for (int i = k - 1; i >= 1; i--) {if (a[i] <= a[i + 1]) k--;else break;}printf("%d\n", k - 1);}return 0;
}

codeforces C. Make It Good相关推荐

  1. CodeForces 375D Tree and Queries

    传送门:https://codeforces.com/problemset/problem/375/D 题意: 给你一颗有根树,树上每个节点都有其对应的颜色,有m次询问,每次问你以点v为父节点的子树内 ...

  2. 「日常训练」Bad Luck Island(Codeforces Round 301 Div.2 D)

    题意与分析(CodeForces 540D) 是一道概率dp题. 不过我没把它当dp做... 我就是凭着概率的直觉写的,还好这题不算难. 这题的重点在于考虑概率:他们喜相逢的概率是多少?考虑超几何分布 ...

  3. 【codeforces 812C】Sagheer and Nubian Market

    [题目链接]:http://codeforces.com/contest/812/problem/C [题意] 给你n个物品; 你可以选购k个物品;则 每个物品有一个基础价值; 然后还有一个附加价值; ...

  4. CodeForces 获得数据

    针对程序的输出可以看见 CodeForces :当输入.输出超过一定字符,会隐藏内容 所以:分若干个程序进行输入数据的获取 1. 1 for (i=1;i<=q;i++) 2 { 3 scanf ...

  5. codeforces水题100道 第二十七题 Codeforces Round #172 (Div. 2) A. Word Capitalization (strings)...

    题目链接:http://www.codeforces.com/problemset/problem/281/A 题意:将一个英文字母的首字母变成大写,然后输出. C++代码: #include < ...

  6. CodeForces 595A

    题目链接: http://codeforces.com/problemset/problem/595/A 题意: 一栋楼,有n层,每层有m户,每户有2个窗户,问这栋楼还有多少户没有睡觉(只要一个窗户灯 ...

  7. codeforces A. Jeff and Digits 解题报告

    题目链接:http://codeforces.com/problemset/problem/352/A 题目意思:给定一个只有0或5组成的序列,你要重新编排这个序列(当然你可以不取尽这些数字),使得这 ...

  8. Codeforces Round #506 (Div. 3)

    Codeforces Round #506 (Div. 3) 实习期间事不多,对div3 面向题解和数据编程了一波 A. Many Equal Substrings 题目链接 A题就是找后缀和前缀重合 ...

  9. Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈)

    Codeforces Round #417:E. FountainsSagheer and Apple Tree(树上博弈) 标签: codeforces 2017-06-02 11:41 29人阅读 ...

  10. [题解]RGB Substring (hard version)-前缀和(codeforces 1196D2)

    题目链接:https://codeforces.com/problemset/problem/1196/D2 题意: q 个询问,每个查询将给你一个由 n 个字符组成的字符串s,每个字符都是 &quo ...

最新文章

  1. 人类应鼎力进行探索的35种颠覆性技术
  2. 如何在Unity中添加三维空间声音Spatial Sounds
  3. 成功解决解决VM软件安装Linux的Ubuntu过程,开启Linux出现Oprating System not found错误
  4. Linux操作系统下三种配置环境变量的方法(linux下几种profile执行顺序)
  5. Akka并发编程——第三节:Actor模型(二)
  6. 超轻量级DI容器框架Google Guice与Spring框架的区别教程详解及其demo代码片段分享...
  7. Delphi关于记录文件的操作
  8. 前端学习(2948):webpack创建简单项目
  9. lamda 对比两个list_正式支持多线程!Redis 6.0与老版性能对比评测
  10. 电脑密码忘记怎么办??
  11. jq中get()和eq()的区别
  12. 用 SQL 脚本读取Excel 中的sheet数量及名称
  13. 分享webStorm汉化
  14. VHDL半整数与奇数分频器设计实验
  15. 微信小程序电子签名实现并识别文字
  16. python少儿编程竞赛_家长必读!国内外含金量最高的编程比赛全在这了!
  17. 多目标优化 MOP (一):遗传算法 SPEA 1999
  18. ssm项目笔记(五)图片存储方案
  19. STM32+ULN2003驱动步进电机
  20. 转:前端 100 问:能搞懂80%的请把简历给我

热门文章

  1. Tomcat8调优核心实战详解
  2. C语言题目:输入一个数,将它的每一位按顺序打印出来
  3. 从零开始写javaweb框架笔记2-搭建web项目框架
  4. 智能手环两极分化:Fitbit卖身,华为小米们扶摇直上
  5. 音频前处理:回声消除、噪声抑制等(音视频SDK高级功能六)
  6. matlab实现差分进化算法DE
  7. linux定时任务 - CRON表达式
  8. matlab GS算法
  9. cityscapes数据集的下载和应用
  10. Java中的反射(Reflection)为什么叫“反射”?什么是“正射”?如何自定义注解并解析?