Educational Codeforces Round 27
来源:互联网 发布:淘宝商品销量查询工具 编辑:程序博客网 时间:2024/06/07 22:51
题意:
给你几个棋手和对应的实力。让你分成2队,1队的所有人都能打败2队的所有人。
POINT:
排序,比较1队的尾巴和2队的头。
#include <iostream>#include <string.h>#include <vector>#include <algorithm>#include <math.h>#include <stdio.h>using namespace std;#define LL long longint main(){ int n; while(~scanf("%d",&n)) { int a[222]; for(int i=1;i<=2*n;i++) { scanf("%d",&a[i]); } sort(a+1,a+1+2*n); if(a[n]<a[n+1]) { printf("YES\n"); } else printf("NO\n"); }}
题意:
给你6个数字,前3个一组,后3个一组,让你改变最少的数字,使他们的数字和相等。可以任意变0-9.
point:
要不就是大的一组减小,要不小的一组增大。先分好。小的一组都9-a[i],代表可以增加的数量。
然后每次让差值减小,贪心减。
赛中做的总是只变化一组,被hack了。
#include <iostream>#include <string.h>#include <vector>#include <algorithm>#include <math.h>#include <stdio.h>using namespace std;#define LL long longint main(){ char s[7]; scanf("%s",s); int a[6]; for(int i=0;i<6;i++) a[i]=s[i]-'0'; int sum1=a[0]+a[1]+a[2]; int sum2=a[3]+a[4]+a[5]; if(sum2==sum1){ printf("0\n"); return 0; } if(sum2>sum1) { swap(a[0],a[3]); swap(a[1],a[4]); swap(a[2],a[5]); swap(sum2,sum1); } a[3]=9-a[3]; a[4]=9-a[4]; a[5]=9-a[5]; int aim=sum1-sum2; sort(a,a+6); int now=0; int p=0; for(int i=5;i>=0;i--) { now+=a[i]; p++; if(aim<=now) break; } printf("%d\n",p); }
题意:
HDU的今年暑假不AC。
注意节目可以从0开始。wa了一次。
#include <iostream>#include <string.h>#include <vector>#include <algorithm>#include <math.h>#include <stdio.h>using namespace std;#define LL long longstruct node{ int b,e;}a[2*100000+6];bool cmd(node a ,node b){ if(a.b!=b.b) { return a.b<b.b; } else return a.e<b.e;}int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d %d",&a[i].b,&a[i].e); } sort(a+1,a+1+n,cmd); int t1=-1,t2=-1; int flag=0; for(int i=1;i<=n;i++) { if(t1<a[i].b) { t1=a[i].e; continue; } else if(t2<a[i].b) { t2=a[i].e; } else { flag=1; break; } } if(flag) printf("NO\n"); else printf("YES\n");}
阅读全文
0 0
- Educational Codeforces Round 27
- Educational Codeforces Round 27
- Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Codeforces Educational Codeforces Round 27
- Educational Codeforces Round 27 ABCD
- Educational Codeforces Round 27 (ABC)
- Codeforces Educational Round 27 总结
- A. Chess Tourney【Educational Codeforces Round 27】
- Educational Codeforces Round 27- D Driving Test
- Educational Codeforces Round 1
- Educational Codeforces Round 2
- Educational Codeforces Round 2
- Educational Codeforces Round 2
- Educational Codeforces Round 3
- Codeforces Educational Round 3
- Android进阶#(4/12)HTTP网络请求_网络框架的设计与实现
- C# 面向对象三大特性:封装、继承、多态
- TASKCTL4.1怎么检测服务是否启动
- 【Java Opencv系列】3.2Mat的线性代数加减乘操作
- 互联网创业|你把网校平台研发好了,运营打算扔给谁?
- Educational Codeforces Round 27
- Redis--protocol(通信协议)
- Linux 生成随机数
- 用FFmpeg玩转Android视频录制与压缩
- 203. Remove Linked List Elements(链表)
- 每天一个linux命令(31): /etc/group文件详解
- [RK3288][Android7.1.2] 预装APK
- Hello 移动Web--pixel像素基础
- Android中shape自定义形状遇到问题