2018国庆第一场个人赛

版权声明:转载时 别忘了注明出处 https://blog.csdn.net/ZCY19990813/article/details/82917567

C - Romaji    CodeForces - 1008A

vowel元音  consonant 辅音

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 s is Berlanese.

Input

The first line of the input contains the string s consisting of |s| (1≤|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).

Sample Input

Input

sumimasen

Output

YES

Input

ninja

Output

YES

Input

codeforces

Output

NO

Hint

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除外)后面必须是元音字母(若最后一个是辅音 输出no)

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
ll flag[1010];
int main()
{
    char s[1010];
    ll n,i,j;
    memset(s,0,sizeof(s));
    gets(s);
    n=strlen(s);
    for(i=0; i<n; i++)
    {
        if(s[i]=='a'||s[i]=='e'||s[i]=='i'||s[i]=='u'||s[i]=='o')
            flag[i]=0;
        else if(s[i]=='n')
            flag[i]=2;
        else
            flag[i]=1;
    }
    if(flag[n-1]==1)
        cout<<"NO"<<endl;
    else
    {
        for(i=0; i<n-1; i++)
        {
            if(flag[i]==1)
            {
                if(flag[i+1]!=0)
                    break;
            }

        }
        if(i>=n-1)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}

A - Turn the Rectangles

CodeForces - 1008B

There are n rectangles in a row. You can either turn each rectangle by 90

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 n(1≤n≤105) — the number of rectangles.

Each of the next n lines contains two integers wi and hi (1≤wi,hi≤109) — the width and the height of the i-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).

Sample Input

Input

3
3 4
4 6
3 5

Output

YES

Input

2
3 4
5 5

Output

NO
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
struct DL
{
    ll a;
    ll b;
}s[101010];
int main()
{
    ll n,i,j,t,p;
    cin>>n;
    for(i=0;i<n;i++)
        cin>>s[i].a>>s[i].b;
    if(s[0].a<s[0].b)
    {
        t=s[0].a;
        s[0].a=s[0].b;
        s[0].b=t;
    }
    p=s[0].a;
    for(i=1;i<n;i++)
    {
        if(s[i].a<=p&&s[i].b<=p)
            p=max(s[i].a,s[i].b);
        else
        if(s[i].a<=p)
           p=s[i].a;
        else
        if(s[i].b<=p)
            p=s[i].b;
        else
            break;

    }
    if(i>=n)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
    return 0;
}

D - Game Shopping

CodeForces - 1009A

Maxim wants to buy some games at the local game shop. There are n games in the shop, the i-th game costs ci.

Maxim has a wallet which can be represented as an array of integers. His wallet contains m bills, the j-th bill has value aj.

Games in the shop are ordered from left to right, Maxim tries to buy every game in that order.

When Maxim stands at the position i in the shop, he takes the first bill from his wallet (if his wallet is empty then he proceeds to the next position immediately) and tries to buy the i-th game using this bill. After Maxim tried to buy the n-th game, he leaves the shop.

Maxim buys the i-th game if and only if the value of the first bill (which he takes) from his wallet is greater or equal to the cost of the i-th game. If he successfully buys the i-th game, the first bill from his wallet disappears and the next bill becomes first. Otherwise Maxim leaves the first bill in his wallet (this bill still remains the first one) and proceeds to the next game.

For example, for array c=[2,4,5,2,4]and array a=[5,3,4,6] the following process takes place: Maxim buys the first game using the first bill (its value is 5), the bill disappears, after that the second bill (with value 3) becomes the first one in Maxim's wallet, then Maxim doesn't buy the second game because c2>a2, the same with the third game, then he buys the fourth game using the bill of value a2 (the third bill becomes the first one in Maxim's wallet) and buys the fifth game using the bill of value a3.

Your task is to get the number of games Maxim will buy.

Input

The first line of the input contains two integers n and m (1≤n,m≤1000) — the number of games and the number of bills in Maxim's wallet.

The second line of the input contains n integers c1,c2,…,cn (1≤ci≤1000), where ci is the cost of the i-th game.

The third line of the input contains m integers a1,a2,…,am (1≤aj≤1000), where aj is the value of the j-th bill from the Maxim's wallet.

Output

Print a single integer — the number of games Maxim will buy.

Examples

Input

5 4
2 4 5 2 4
5 3 4 6

Output

3

Input

5 2
20 40 50 20 40
19 20

Output

0

Input

6 4
4 8 15 16 23 42
1000 1000 1000 1000

Output

4

 题意:Maxim要去商店买东西 商店东西的价格 自己有的钱数已经给出 商店东西的位置不能改变 他从左往右买 能买就买 不能买到下一个地方 问他能买几件东西

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <deque>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
deque <ll> a,b;
int main()
{
    ll n,m,x,y,i,sum=0;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>x;
        a.push_back(x);
    }
    for(i=0;i<m;i++)
    {
        cin>>x;
        b.push_back(x);
    }
    while(1)
    {
        if(a.empty())
            break;
        if(b.empty())
            break;
        x=a.front();
        y=b.front();
        if(y>=x)
        {
            a.pop_front();
            b.pop_front();
            sum++;
        }
        else
        {
            a.pop_front();
        }
    }
    cout<<sum<<endl;
    return 0;
}

猜你喜欢

转载自blog.csdn.net/ZCY19990813/article/details/82917567