标签:ons its cin style src codeforce class contest const
代码:
#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\n", ans); return 0; }
代码:
#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\n"); else if(s[N - 1] == ‘<‘) printf("0\n"); 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\n", min(st, N - 1 - en)); } } return 0; }
Educational Codeforces Round 62
标签:ons its cin style src codeforce class contest const
原文地址:https://www.cnblogs.com/zlrrrr/p/10713874.html