Warning: session_start(): open(/tmp/sess_d7f2744f318b7ed0fdf0be02e37fc93e, O_RDWR) failed: No space left on device (28) in /data/wiki/inc/init.php on line 239

Warning: session_start(): Failed to read session data: files (path: ) in /data/wiki/inc/init.php on line 239

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/auth.php on line 430
Writing /data/wiki/data/cache/d/de2edb2fcb553ea79b79c722a4e13dbc.captchaip failed

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/inc/actions.php on line 38

Warning: Cannot modify header information - headers already sent by (output started at /data/wiki/inc/init.php:239) in /data/wiki/lib/tpl/dokuwiki/main.php on line 12
2020-2021:teams:manespace:codeforces_round_656_div._3 [CVBB ACM Team]

用户工具

站点工具


2020-2021:teams:manespace:codeforces_round_656_div._3

到此差别页面的链接

两侧同时换到之前的修订记录 前一修订版
2020-2021:teams:manespace:codeforces_round_656_div._3 [2020/07/24 11:41]
intouchables
2020-2021:teams:manespace:codeforces_round_656_div._3 [2020/07/24 11:43] (当前版本)
intouchables [C]
行 87: 行 87:
  
   *题意:定义“good”序列:每次从首位或末位拿出元素,组成的新序列单调不降。多组数据,给定序列,询问删去从首位开始的至少多少元素,可以使序列成为“good”序列?   *题意:定义“good”序列:每次从首位或末位拿出元素,组成的新序列单调不降。多组数据,给定序列,询问删去从首位开始的至少多少元素,可以使序列成为“good”序列?
-  *题解:+  *题解:所谓“good”序列就是从首末开始到某一位置都单调不降的序列,只需倒序遍历,先找不降序列,由此后找不升序列,统计剩余元素个数输出即可
 <hidden ac代码>​ <hidden ac代码>​
 <code c++> <code c++>
 +#​include<​bits/​stdc++.h>​
 +using namespace std;
  
 +typedef long long ll;
 +const int maxn = 2e5 + 5;
 +const double pi = acos(-1);
 +const int mod = 998244353;
 +
 +int t;
 +int n;
 +int a[maxn];
 +
 +int main(){
 + cin >> t;
 + while(t--){
 + cin >> n;
 + for(int i = 1; i <= n; ++i) cin >> a[i];
 + if(n == 1){
 + cout << 0 << endl;
 + continue;​
 + }
 + int p = -1, q = -1;
 + for(int i = n; i > 1; --i){
 + if(a[i-1] < a[i]){
 + p = i;
 + break;
 + }
 + }
 + if(p == -1){
 + cout << 0 << endl;
 + continue;​
 + }
 + for(int i = p; i > 1; --i){
 + if(a[i-1] > a[i]){
 + q = i;
 + break;
 + }
 + }
 + if(q == -1) cout << 0 << endl;
 + else cout << q - 1 << endl;
 + }
 +
 </​code>​ </​code>​
 </​hidden>​ </​hidden>​
2020-2021/teams/manespace/codeforces_round_656_div._3.1595562067.txt.gz · 最后更改: 2020/07/24 11:41 由 intouchables