Codeforces Round #429
来源:互联网 发布:jy零食淘宝店网址 编辑:程序博客网 时间:2024/06/05 04:13
CF841A Generous Kefa(模拟)
#include <bits/stdc++.h>inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return x*f;}inline int min(int x,int y){return x<y?x:y;}inline int max(int x,int y){return x>y?x:y;}#define N 105char s[N];int n,k,num['z'+1],ans=0;int main(){// freopen("a.in","r",stdin); n=read();k=read();scanf("%s",s+1); for(int i=1;i<=n;++i) num[s[i]]++; for(int i='a';i<='z';++i) ans=max(ans,num[i]); if(ans<=k) puts("YES"); else puts("NO"); return 0;}
CF841B Godsend(博弈+数学)
显然只有全是偶数第二人才可能赢。
#include <bits/stdc++.h>inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return x*f;}inline int min(int x,int y){return x<y?x:y;}inline int max(int x,int y){return x>y?x:y;}int n;int main(){// freopen("a.in","r",stdin); n=read(); for(int i=1;i<=n;++i){ int x=read(); if(x&1){puts("First");return 0;} } puts("Second"); return 0;}
CF840A Leha and Function(贪心+组合数学)
人话题意:把A数组重排一下,使得函数值之和最大。
推导(猜)一下,发现n一定时,k越小函数值越大。所以我们对a从大到小排序,对b从小到大排序,对应的就是答案了。
#include <bits/stdc++.h>inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(); return x*f;}inline int min(int x,int y){return x<y?x:y;}inline int max(int x,int y){return x>y?x:y;}#define N 200010int n,a[N],ans[N];struct node{ int x,pos;}b[N];inline bool cmp1(int x,int y){return x>y;}inline bool cmp2(node x,node y){return x.x<y.x;}int main(){// freopen("a.in","r",stdin); n=read(); for(int i=1;i<=n;++i) a[i]=read(); for(int i=1;i<=n;++i) b[i].x=read(),b[i].pos=i; std::sort(a+1,a+n+1,cmp1);std::sort(b+1,b+n+1,cmp2); for(int i=1;i<=n;++i) ans[b[i].pos]=a[i]; for(int i=1;i<=n;++i) printf("%d ",ans[i]); return 0;}
阅读全文
1 0
- Codeforces Round #429
- Codeforces Round #429
- Codeforces round#429 div2 C
- Codeforces Round#429 B-Godesend
- Codeforces Round #429(Div 1)
- Codeforces Round #429 (Div. 2)
- Codeforces Round #429 (Div. 2)
- Codeforces Round #429 (Div2) B
- Codeforces Round #429 (Div2) C
- 【codeforces】Codeforces Round #363
- Codeforces Round #429 (Div. 2):B. Godsend
- Codeforces Round #429 (Div. 2) 题解
- Codeforces Round #429 (Div. 2) | B. Godsend
- Codeforces Round #429 (Div. 2)-(DFS)
- Codeforces Round #429 (Div. 2) 总结
- Codeforces Round #429 (Div. 2) ABC
- Codeforces Round #429 (Div 2) A
- Codeforces Round #429 (Div. 2) D
- 如何将Markdown文章轻松地搬运到微信公众号并完美地呈现代码内容
- 各编译器对C++11的支持情况对比
- HDU 6068 Classic Quotation(2017 Multi-University Training Contest 4)
- ARM汇编指令
- js
- Codeforces Round #429
- SQL Server的常用数据类型(字符型)的区别
- bzoj3675 [ APIO2014 ] -- 斜率优化DP
- 如何运行vue项目
- Redux笔记
- 例说数据结构&STL(十三)——pair
- 指针和数组
- Unity3D实现宠物跟随主角的效果图
- selenium的使用和scrapy的简单使用