Round #429 (Div.2)

---恢复内容开始---

One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si — lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give out all baloons to his friends. Help Kefa to find out, can he give out all his baloons, such that no one of his friens will be upset — print ?YES?, if he can, and ?NO?, otherwise. Note, that Kefa‘s friend will not upset, if he doesn‘t get baloons at all.

Input

The first line contains two integers n and k (1?≤?n,?k?≤?100) — the number of baloons and friends.

Next line contains string s — colors of baloons.

Output

Answer to the task — ?YES? or ?NO? in a single line.

You can choose the case (lower or upper) for each letter arbitrary.

Examples

Input

4 2aabb

Output

YES

Input

6 3aacaab

Output

NO

Note

In the first sample Kefa can give 1-st and 3-rd baloon to the first friend, and 2-nd and 4-th to the second.

In the second sample Kefa needs to give to all his friends baloons of color a, but one baloon will stay, thats why answer is ?NO?.

题意:Kefa有n个气球,26个小写字母表示颜色,k个朋友,他要把气球分给k个朋友,但是朋友要得到不同的颜色,否则就是NO

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <algorithm>
 4 using namespace std;
 5 int a[26];
 6 int n,k,m;
 7 bool cmp(int x,int y){
 8     return x>y;
 9 }
10 int main(){
11     cin>>n>>k;
12     m=k;
13     for(int i=1;i<=n;i++){
14     char x;
15     scanf(" %c",&x);
16     a[x-‘a‘]++;  //标记每种颜色气球的数量
17 18     sort(a,a+26,cmp);  //从大到小排序,例2:a[0]=4
19     a[0]>k?printf("NO\n"):printf("YES\n");  //4>3 NO
20     return 0;
21 }

Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an odd sum of numbers and remove it from the array, after that the remaining parts are glued together into one array and the game continues. The second player can choose a subsegment of non-zero length with an even sum and remove it. Loses the one who can not make a move. Who will win if both play optimally?

Input

First line of input data contains single integer n (1?≤?n?≤?106) — length of the array.

Next line contains n integers a1,?a2,?...,?an (0?≤?ai?≤?109).

Output

Output answer in single line. "First", if first player wins, and "Second" otherwise (without quotes).

Examples

Input

41 3 2 3

Output

First

Input

22 2

Output

Second

Note

In first sample first player remove whole array in one move and win.

In second sample first player can‘t make a move and lose

n个数和为偶要分情况讨论,为奇first胜,

 1 #include <iostream>
 2 #include <stdio.h>
 3 using namespace std;
 4 int main(){
 5     int n,m,sum=0,t;
 6     scanf("%d",&n);
 7     for(int i=0;i<n;i++){
 8     scanf("%d",&m);
 9     if(m&1) t++;   //奇数
10     sum+=m;
11     }
12     if(sum&1) printf("First\n");   //为奇
13     else {
14     if(t==0) printf("Second\n");
15     else printf("First\n");
16     }
17     return 0;
18 }

 or................................................................................or..............................................................................or

 1 #include <iostream>
 2 #include <stdio.h>
 3 using namespace std;
 4 int main(){
 5     int n,m,s=0;
 6     scanf("%d",&n);
 7     for(int i=1;i<=n;i++){
 8     scanf("%d",&m);
 9     if(m&1) s=1;
10     }
11     if(s) printf("First\n");
12     else printf("Second\n");
13     return 0;
14 }

Leha like all kinds of strange things. Recently he liked the function F(n,?k). Consider all possible k-element subsets of the set [1,?2,?...,?n]. For subset find minimal element in it. F(n,?k) — mathematical expectation of the minimal element among all k-element subsets.

But only function does not interest him. He wants to do interesting things with it. Mom brought him two arrays A and B, each consists of m integers. For all i,?j such that 1?≤?i,?j?≤?m the condition Ai?≥?Bj holds. Help Leha rearrange the numbers in the array A so that the sum is maximally possible, where A‘ is already rearranged array.

Input

First line of input data contains single integer m (1?≤?m?≤?2·105) — length of arrays A and B.

Next line contains m integers a1,?a2,?...,?am (1?≤?ai?≤?109) — array A.

Next line contains m integers b1,?b2,?...,?bm (1?≤?bi?≤?109) — array B.

Output

Output m integers a1,?a2,?...,?am — array A‘ which is permutation of the array A.

Examples

Input

57 3 5 3 42 1 3 2 3

Output

4 7 3 5 3

Input

74 6 5 8 8 2 62 1 2 2 1 1 2

Output

2 6 4 5 8 8 6
 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <algorithm>
 4
 5 #define maxn 200001
 6 using namespace std;
 7 int a[maxn],n;
 8 pair<int ,int>b[maxn];
 9 bool cmp(int a,int b){
10     return a>b;
11 }
12 bool cmp2(pair<int,int>a,pair<int,int>b){
13     return a.first<b.first;
14 }
15 bool cmp3(pair<int,int>a,pair<int,int>b){
16         return a.second<b.second;
17 }
18 int main(){
19     cin>>n;
20     for(int i=1;i<=n;i++)
21         cin>>a[i];
22     sort(a+1,a+1+n,cmp);
23     for(int i=1;i<=n;i++){
24     cin>>b[i].first;
25     b[i].second=i;
26     }
27     sort(b+1,b+n+1,cmp2);
28     for(int i=1;i<=n;i++)
29         b[i].first=a[i];
30     sort(b+1,b+1+n,cmp3);
31     for(int i=1;i<=n;i++)
32         cout<<b[i].first<<‘ ‘;
33     return 0;
34 }

---恢复内容结束---

时间: 2024-10-14 04:30:19

Round #429 (Div.2)的相关文章

CodeForces 840B - Leha and another game about graph | Codeforces Round #429(Div 1)

思路来自这里,重点大概是想到建树和无解情况,然后就变成树形DP了- - /* CodeForces 840B - Leha and another game about graph [ 增量构造,树上差分 ] | Codeforces Round #429(Div 1) 题意: 选择一个边集合,满足某些点度数的奇偶性 分析: 将d = 1的点连成一颗树,不在树上的点都不连边. 可以发现,当某个节点u的所有子节点si均可操控 (u, si) 来满足自身要求 即整棵树上至多只有1个点不满足自身要求,

CodeForces 840A - Leha and Function | Codeforces Round #429 (Div. 1)

/* CodeForces 840A - Leha and Function [ 贪心 ] | Codeforces Round #429 (Div. 1) A越大,B越小,越好 */ #include <bits/stdc++.h> using namespace std; const int N = 2e5+5; int a[N], b[N], c[N], n; int aa[N], bb[N]; bool cmp1(int x, int y) { return a[x] > a[y

【推导】【DFS】Codeforces Round #429 (Div. 1) B. Leha and another game about graph

题意:给你一张图,给你每个点的权值,要么是-1,要么是1,要么是0.如果是-1就不用管,否则就要删除图中的某些边,使得该点的度数 mod 2等于该点的权值.让你输出一个留边的方案. 首先如果图内有-1,那么必有解.否则如果初始不合法的点数为偶数,那么必有解,否则无解.因为删一条边,要么使图中不合法的点数+2,要么不变,要么-2. 如果有解,构造图的任意一个生成树,如果有-1,就让-1为根,否则任意结点为根.然后从叶子向根定每个点的入度数,由于自底向上,一个结点的儿子边都被处理完后,只需要决定父边

Codeforces Round#429(Div.2)

A. Generous Kefa 如果有字母的个数大于k则NO #include<bits/stdc++.h> using namespace std; int arr[28],n,k; string str; int main(){ cin>>n>>k; cin>>str; for(int i = 0;i<str.length();i++){ arr[(int)(str[i]-'a')]++; } for(int i = 0;i<26;i++)

【CodeForces】841C. Leha and Function(Codeforces Round #429 (Div. 2))

[题意]定义函数F(n,k)为1~n的集合中选择k个数字,其中最小数字的期望. 给定两个数字集A,B,A中任意数字>=B中任意数字,要求重组A使得对于i=1~n,sigma(F(Ai,Bi))最大. [算法]数学结论+数学期望+排序 [题解]很无奈,这题放在div2 C,难以推导的期望公式,广为人知的结论,容易观察样例得出的做法,都体现了这道题的不合理性. F(n,k)=(n+1)/(k+1) 公式推导可能触及我的知识盲区了QAQ 得到公式后,显然要求k尽可能小,n尽可能大,经验告诉我们随着两数

Codeforces Round #429 (Div. 2) 841A. Generous Kefa(签到题)

A. Generous Kefa One day Kefa found n baloons. For convenience, we denote color of i-th baloon as si - lowercase letter of the Latin alphabet. Also Kefa has k friends. Friend will be upset, If he get two baloons of the same color. Kefa want to give o

Codeforces Round #429 (Div. 2)ABC

A: 题意:n个东西,k个朋友,全部给朋友,每个朋友不可以拿同样的,问是否可行 1 #include<bits/stdc++.h> 2 using namespace std; 3 4 map<char ,int >ma; 5 int main(){ 6 int n,k; 7 cin>>n>>k; 8 string s; 9 cin>>s; 10 for(int i=0;i<n;i++){ 11 ma[s[i]]++; 12 if(ma[s

Codeforces Round #429 (Div. 2) 841B Godsend(签到题)

B. Godsend Leha somehow found an array consisting of n integers. Looking at it, he came up with a task. Two players play the game on the array. Players move one by one. The first player can choose for his move a subsegment of non-zero length with an

Codeforces Round #428 (Div. 2)

Codeforces Round #428 (Div. 2) A    看懂题目意思就知道做了 #include<bits/stdc++.h> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define rep(i,a,b) for (int i=a; i<=b; ++i) #define per(i,b,a) for (int i=b; i>=a; --i