Featured image of post Codeforces Round #497 (Div. 2)

Codeforces Round #497 (Div. 2)

A Romaji

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include<iostream>
  
using namespace std;
  
string str;
  
bool check(char c)
{
    if(c=='a' || c=='o' || c=='u' || c=='i' || c=='e')
        return true;
    else
        return false;
}
  
int main()
{
    cin>>str;
    for(int i=0;i<str.size();i++)
    {
        if(str[i]=='n')
            continue;
        else if(check(str[i]))
            continue;
        else if(!check(str[i+1]))
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

B Turn the Rectangles

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include<iostream>
#include<algorithm>
  
using namespace std;
  
struct node
{
    int x,y;
}a[100003];
  
int n;
  
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i].x>>a[i].y;
    int h=max(a[1].x,a[1].y);
    for(int i=1;i<n;i++)
    {
        if(h>=a[i+1].x && h>=a[i+1].y)
        {
            h=max(a[i+1].x,a[i+1].y);
            continue;
        }
        else if(h>=a[i+1].x)
        {
            h=a[i+1].x;
            continue;
        }
        else if(h>=a[i+1].y)
        {
            h=a[i+1].y;
            continue;
        }
        else
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}

C Reorder the Array

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include<iostream>
#include<algorithm>
  
using namespace std;
  
int n,ans,tmp;
int a[100003];
  
bool cmp(int a,int b)
{
    return a>b;
}
  
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    for(int i=0;i<=n;i++)
    {
        if(a[i]==a[i+1])
            tmp++;
        else
        {
            ans=max(ans,tmp);
            tmp=1;
        }
    }
    cout<<n-ans<<endl;
    return 0;
}
Built with Hugo
主题 StackJimmy 设计