• Codeforces Round #497 (Div. 2) ABC


    A. Romaji

    Vitya has just started learning Berlanese language. It is known that Berlanese uses the Latin alphabet. Vowel letters are "a", "o", "u", "i", and "e". Other letters are consonant.

    In Berlanese, there has to be a vowel after every consonant, but there can be any letter after any vowel. The only exception is a consonant "n"; after this letter, there can be any letter (not only a vowel) or there can be no letter at all. For example, the words "harakiri", "yupie", "man", and "nbo" are Berlanese while the words "horse", "king", "my", and "nz" are not.

    Help Vitya find out if a word ss is Berlanese.

    Input

    The first line of the input contains the string ss consisting of |s||s| (1|s|1001≤|s|≤100) lowercase Latin letters.

    Output

    Print "YES" (without quotes) if there is a vowel after every consonant except "n", otherwise print "NO".

    You can print each letter in any case (upper or lower).

    Examples
    input
    Copy
    sumimasen
    output
    Copy
    YES
    input
    Copy
    ninja
    output
    Copy
    YES
    input
    Copy
    codeforces
    output
    Copy
    NO
    Note

    In the first and second samples, a vowel goes after each consonant except "n", so the word is Berlanese.

    In the third sample, the consonant "c" goes after the consonant "r", and the consonant "s" stands on the end, so the word is not Berlanese.

    辅音字母除n外后面是否都有元音字母

     1 #include <bits/stdc++.h>
     2 #define ll long long
     3 using namespace std;
     4 const int N = 1e5+10;
     5 char str[110];
     6 map<char,int> mp;
     7 int main() {
     8     mp['e'] = mp['a'] = mp['o'] = mp['u'] = mp['i'] = 1;
     9     cin >> str;
    10     for(int i = 0; str[i]; i ++) {
    11         if(str[i] == 'n') continue;
    12         if(mp[str[i]] == 0 ) {
    13             if(mp[str[i+1]] != 1) {
    14                 // printf("%c %c
    ",str[i],str[i+1] );
    15                 return 0*printf("no
    ");
    16             }
    17         }
    18     }printf("yes
    ");
    19     return 0;
    20 }

    B. Turn the Rectangles

    There are nn rectangles in a row. You can either turn each rectangle by 9090 degrees or leave it as it is. If you turn a rectangle, its width will be height, and its height will be width. Notice that you can turn any number of rectangles, you also can turn all or none of them. You can not change the order of the rectangles.

    Find out if there is a way to make the rectangles go in order of non-ascending height. In other words, after all the turns, a height of every rectangle has to be not greater than the height of the previous rectangle (if it is such).

    Input

    The first line contains a single integer nn (1n1051≤n≤105) — the number of rectangles.

    Each of the next nn lines contains two integers wiwi and hihi (1wi,hi1091≤wi,hi≤109) — the width and the height of the ii-th rectangle.

    Output

    Print "YES" (without quotes) if there is a way to make the rectangles go in order of non-ascending height, otherwise print "NO".

    You can print each letter in any case (upper or lower).

    Examples
    input
    Copy
    3
    3 4
    4 6
    3 5
    output
    Copy
    YES
    input
    Copy
    2
    3 4
    5 5
    output
    Copy
    NO
    Note

    In the first test, you can rotate the second and the third rectangles so that the heights will be [4, 4, 3].

    In the second test, there is no way the second rectangle will be not higher than the first one.

    有一个位置有两个数字,通过适当的选择是否存在递减序列

     1 #include <bits/stdc++.h>
     2 #define ll long long
     3 using namespace std;
     4 const int N = 1e5+10;
     5 int x[N], y[N];
     6 int main() {
     7     int n;
     8     cin >> n;
     9     for(int i = 1; i <= n; i ++) cin >> x[i] >> y[i];
    10     int cnt = max(x[1],y[1]);
    11     for(int i = 2; i <= n; i ++) {
    12         if(cnt >= max(x[i],y[i])) {
    13             cnt = max(x[i],y[i]);
    14         } else if(cnt >= min(x[i],y[i])) {
    15             cnt = min(x[i], y[i]);
    16         } else return 0*printf("NO
    ");
    17     }
    18     printf("YES
    ");
    19     return 0;
    20 }

    C. Reorder the Array

    You are given an array of integers. Vasya can permute (change order) its integers. He wants to do it so that as many as possible integers will become on a place where a smaller integer used to stand. Help Vasya find the maximal number of such integers.

    For instance, if we are given an array [10,20,30,40][10,20,30,40], we can permute it so that it becomes [20,40,10,30][20,40,10,30]. Then on the first and the second positions the integers became larger (20>1020>10, 40>2040>20) and did not on the third and the fourth, so for this permutation, the number that Vasya wants to maximize equals 22. Read the note for the first example, there is one more demonstrative test case.

    Help Vasya to permute integers in such way that the number of positions in a new array, where integers are greater than in the original one, is maximal.

    Input

    The first line contains a single integer nn (1n1051≤n≤105) — the length of the array.

    The second line contains nn integers a1,a2,,ana1,a2,…,an (1ai1091≤ai≤109) — the elements of the array.

    Output

    Print a single integer — the maximal number of the array's elements which after a permutation will stand on the position where a smaller element stood in the initial array.

    Examples
    input
    Copy
    7
    10 1 1 1 5 5 3
    output
    Copy
    4
    input
    Copy
    5
    1 1 1 1 1
    output
    Copy
    0
    Note

    In the first sample, one of the best permutations is [1,5,5,3,10,1,1][1,5,5,3,10,1,1]. On the positions from second to fifth the elements became larger, so the answer for this permutation is 4.

    In the second sample, there is no way to increase any element with a permutation, so the answer is 0.

    最多存在多少个将大的数字放在小的数字上。

     1 #include <bits/stdc++.h>
     2 #define ll long long
     3 using namespace std;
     4 const int N = 1e5+10;
     5 int n, a[N];
     6 int main() {
     7     cin >> n;
     8     for(int i = 0; i < n; i ++) cin >> a[i];
     9     sort(a,a+n);
    10     int tmp = n-2;
    11     int ans = 0;
    12     for(int i = n-1; i >= 0; i --) {
    13         while(a[tmp] >= a[i] && tmp >= 0) tmp--;
    14         if(tmp < 0) break;
    15         ans++;tmp--;
    16 
    17     }
    18     cout << ans << endl;
    19     return 0;
    20 }
  • 相关阅读:
    (转)Web自动化测试中的接口测试
    Redis在.net中的应用学习
    Redis学习第八课:Redis高级实用特性(一)
    Redis学习第七课:键值命令和服务器命令
    Redis学习第六课:Redis ZSet类型及操作
    先验概率 vs 后验概率
    cout格式化输出
    python练习linux下创建路径
    把“苹果中国首发”视为扬眉吐气是自卑的表现
    字符串处理算法(三)按指定位置交换字符串两部分的位置
  • 原文地址:https://www.cnblogs.com/xingkongyihao/p/9308711.html
Copyright © 2020-2023  润新知