博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #429 (Div. 2)
阅读量:7051 次
发布时间:2019-06-28

本文共 4566 字,大约阅读时间需要 15 分钟。

A. Generous Kefa
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 2 aabb
output
YES
input
6 3 aacaab
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».

 

 hash映射过去,有个字母大于k就是upset

#include 
using namespace std;int a[256];int main(){ int n,k; cin>>n>>k; string s; cin>>s; for(int i=0; s[i]; i++) a[s[i]]++; for(int i=0; i<256; i++) if(a[i]>k) { return 0*printf("NO"); } printf("YES"); return 0;}
B. Godsend
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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
4 1 3 2 3
output
First
input
2 2 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.

 

 去奇数偶数和的子段,这个就是根据奇偶分析啊,有奇数的第一个人就会赢

听说数据量会卡cin

#include 
using namespace std;const int N=1e6+5;int a[N];int main(){ int n,f=0; scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%d",&a[i]); if(a[i]&1)f=1; } printf(f?"First":"Second"); return 0;}
C. Leha and Function
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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 Aand 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 a'1, a'2, ..., a'm — array A' which is permutation of the array A.

Examples
input
5 7 3 5 3 4 2 1 3 2 3
output
4 7 3 5 3
input
7 4 6 5 8 8 2 6 2 1 2 2 1 1 2
output
2 6 4 5 8 8 6

 

 类似于基数排序,蜜汁wa了n发,好像是输出出了差错

#include 
using namespace std;const int N=2e5+5;struct SB{ int a,b; bool friend operator < (SB x,SB y) { return x.a
()); sort(S+1,S+n+1); for(int i=1; i<=n; i++) A[S[i].b]=c[i]; printf("%d",A[1]); for(int i=2; i<=n; i++) printf(" %d",A[i]); return 0;}

 

转载于:https://www.cnblogs.com/BobHuang/p/7395486.html

你可能感兴趣的文章
PostgreSQL 10.1 手册_部分 III. 服务器管理_第 16 章 从源代码安装_16.1. 简单版
查看>>
springMVC的事务不回滚
查看>>
WPF与缓动(三) 指数缓动
查看>>
UPS电源和EPS电源的主要区别
查看>>
Hadoop数据目录迁移
查看>>
Mockplus原型交互跟我做之1 - 30秒做一个自动消失的消息框(Toast)
查看>>
房价数据转换和清洗
查看>>
工业互联网公司寄云科技完成近亿元B轮融资,达晨创投领投
查看>>
springboot 详解 (二) crud
查看>>
从旅行箱到旅行美学品牌,ITO获数千万A轮融资
查看>>
Ant Design 3.16.0 发布,企业级 UI 设计语言
查看>>
less学习-混合
查看>>
Fast特征点的寻找和提取
查看>>
SpringBoot抛出ContextPath must start with xx and not end with xx异常
查看>>
JDK11新特性解读
查看>>
用JAVA写一个冒泡排序
查看>>
【网络新功能】NAT网关和弹性公网IP一键组合购买,开通效率提升一倍
查看>>
03.设计模式-单例模式
查看>>
轻松搞定RabbitMQ1:RabbitMQ与AMQP协议简介
查看>>
MySQL主从同步报error 1236
查看>>