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\n",str[i],str[i+1] );
15                 return 0*printf("no\n");
16             }
17         }
18     }printf("yes\n");
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\n");
17     }
18     printf("YES\n");
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 }

 

转载于:https://www.cnblogs.com/xingkongyihao/p/9308711.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
提供的源码资源涵盖了安卓应用、小程序、Python应用和Java应用等多个领域,每个领域都包含了丰富的实例和项目。这些源码都是基于各自平台的最新技术和标准编写,确保了在对应环境下能够无缝运行。同时,源码中配备了详细的注释和文档,帮助用户快速理解代码结构和实现逻辑。 适用人群: 这些源码资源特别适合大学生群体。无论你是计算机相关专业的学生,还是对其他领域编程感兴趣的学生,这些资源都能为你提供宝贵的学习和实践机会。通过学习和运行这些源码,你可以掌握各平台开发的基础知识,提升编程能力和项目实战经验。 使用场景及目标: 在学习阶段,你可以利用这些源码资源进行课程实践、课外项目或毕业设计。通过分析和运行源码,你将深入了解各平台开发的技术细节和最佳实践,逐步培养起自己的项目开发和问题解决能力。此外,在求职或创业过程中,具备跨平台开发能力的大学生将更具竞争力。 其他说明: 为了确保源码资源的可运行性和易用性,特别注意了以下几点:首先,每份源码都提供了详细的运行环境和依赖说明,确保用户能够轻松搭建起开发环境;其次,源码中的注释和文档都非常完善,方便用户快速上手和理解代码;最后,我会定期更新这些源码资源,以适应各平台技术的最新发展和市场需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值