Educational Codeforces Round 62
Posted zlrrrr
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Educational Codeforces Round 62相关的知识,希望对你有一定的参考价值。
A. Detective Book
代码:
#include <bits/stdc++.h> using namespace std; const int maxn = 1e4 + 10; int N; int a[maxn]; int maxx = 0; int main() { scanf("%d", &N); for(int i = 0; i < N; i ++) scanf("%d", &a[i]); int ans = 0; for(int i = 0; i < N; i ++) { maxx = max(a[i], maxx); if(maxx == i + 1) ans ++; } printf("%d ", ans); return 0; }
B. Good String
代码:
#include <bits/stdc++.h> using namespace std; int T, N; string s; int main() { scanf("%d", &T); while(T --) { scanf("%d", &N); cin >> s; int st, en; if(s[0] == ‘>‘) printf("0 "); else if(s[N - 1] == ‘<‘) printf("0 "); else { for(int i = 0; i < N; i ++) { if(s[i] == ‘>‘) { st = i; break; } } for(int i = N - 1; i >= 0; i --) { if(s[i] == ‘<‘) { en = i; break; } } printf("%d ", min(st, N - 1 - en)); } } return 0; }
以上是关于Educational Codeforces Round 62的主要内容,如果未能解决你的问题,请参考以下文章
Educational Codeforces Round 7 A
Educational Codeforces Round 7
Educational Codeforces Round 90
Educational Codeforces Round 33