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\n", 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\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;
}

原文地址:https://www.cnblogs.com/zlrrrr/p/10713874.html

时间: 2024-10-12 15:55:56

Educational Codeforces Round 62的相关文章

Educational Codeforces Round 62 (Rated for Div. 2)

layout: post title: Educational Codeforces Round 62 (Rated for Div. 2) author: "luowentaoaa" catalog: true tags: mathjax: true - codeforces - dp --- " target="_blank" style="font-size:24px;">传送门 D - Minimum Triangulat

Educational Codeforces Round 62 做题记录

A. 题解: 发现就是找前缀 max = i 的点的个数,暴力扫一遍 1 #include<bits/stdc++.h> 2 #define ll long long 3 #define pii pair<int,int> 4 #define mp(a,b) make_pair(a,b) 5 using namespace std; 6 #define maxn 10005 7 int n; 8 int a[maxn]; 9 int main() 10 { 11 scanf(&qu

C. Playlist Educational Codeforces Round 62 (Rated for Div. 2) 贪心+优先队列

C. Playlist time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a playlist consisting of nn songs. The ii-th song is characterized by two numbers titi and bibi — its length and beauty

Educational Codeforces Round 21 G. Anthem of Berland(dp+kmp)

题目链接:Educational Codeforces Round 21 G. Anthem of Berland 题意: 给你两个字符串,第一个字符串包含问号,问号可以变成任意字符串. 问你第一个字符串最多包含多少个第二个字符串. 题解: 考虑dp[i][j],表示当前考虑到第一个串的第i位,已经匹配到第二个字符串的第j位. 这样的话复杂度为26*n*m*O(fail). fail可以用kmp进行预处理,将26个字母全部处理出来,这样复杂度就变成了26*n*m. 状态转移看代码(就是一个kmp

Educational Codeforces Round 23 F. MEX Queries(线段树)

题目链接:Educational Codeforces Round 23 F. MEX Queries 题意: 一共有n个操作. 1.  将[l,r]区间的数标记为1. 2.  将[l,r]区间的数标记为0. 3.  将[l,r]区间取反. 对每个操作,输出标记为0的最小正整数. 题解: hash后,用线段树xjb标记一下就行了. 1 #include<bits/stdc++.h> 2 #define ls l,m,rt<<1 3 #define rs m+1,r,rt<&l

Educational Codeforces Round 21 F. Card Game(网络流之最大点权独立集)

题目链接:Educational Codeforces Round 21 F. Card Game 题意: 有n个卡片,每个卡片有三个值:p,c,l; 现在让你找一个最小的L,使得满足选出来的卡片l<=L,并且所有卡片的p的和不小于k. 选择卡片时有限制,任意两张卡片的c之和不能为质数. 题解: 和hdu 1565 方格取数(2)一样,都是求最大点权独立集. 不难看出来,这题再多一个二分. 注意的是在构造二部图的时候,按照c值的奇偶性构造. 当c==1时要单独处理,因为如果有多个c==1的卡片,

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is