A:Level Statistics

题意:统计n个游戏数据,p代表游玩次数,c代表通关次数,每次游玩都不一定通关,求这些数据是否合法

题解:1.游玩次数不能小于通关次数   2.游玩次数和通关次数必须单增  3.每次增加的游玩次数不能小于通关次数

代码:

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 int n;
26 int p,c,mp=0,mc=0,tp=0,tc=0;
27
28 int main() {
29 ios::sync_with_stdio(false);
30 cin>>t;
31 while(t--){
32 tp=0,tc=0;
33 bool flag=1;
34 cin>>n;
35 for(int i=0;i<n;++i){
36 cin>>p>>c;
37 if(i==0) tp=p,tc=c;
38 if(p<tp || c<tc || (p==tp && c>tc) || p<c || (p-tp<c-tc)){
39 flag=0;
40 }
41 tp=p;
42 tc=c;
43 }
44 if(flag==0) printf("NO\n");
45 else printf("YES\n");
46 }
47
48 return 0;
49 }

B. Middle Class

题意:定义每人拥有的钱不小于x时为富人,现在有n个人,可以选(1<=x<=n)个人出来将他们的财产平分给所有人,求最多能有多少富人

题解:对每个人拥有的钱排个序,然后贪心,从最有钱的人开始往前遍历,记录一个最大值即可

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 int n;
26 long double x,sum[N];
27 int ans=0;
28 long double a[N];
29 int main() {
30 ios::sync_with_stdio(false);
31 cin>>t;
32 while(t--){
33 cin>>n>>x;
34 ans=0;
35 for(int i=0;i<n;++i){
36 cin>>a[i];
37 }
38 sort(a,a+n);
39 for(int i=n-1;i>=0;--i){
40 sum[n-i]=sum[n-i-1]+a[i];
41 }
42 for(int i=1;i<=n;++i){
43 long double tmp=sum[i]/i;
44 if(tmp>=x){
45 ans=max(ans,i);
46 }
47 }
48 printf("%d\n",ans);
49 }
50
51
52
53 return 0;
54 }

C. Circle of Monsters

题意:有n个怪物围成一个圈,每次攻击可以对怪物造成一点伤害,当第i个怪物扑街后会对后面一个(n的后面是1)怪物造成b[i]点伤害(如果i+1个怪物存活的话),求最少攻击多少次能将怪物全部消灭

题解:枚举每个怪物受到前一个怪物的阵亡伤害,然后按顺序遍历一边求个最小值就行了(建议用scanf和pritnf,容易T)

代码:

 1 #include <iostream>
2 #include <cstdio>
3 #include <cstring>
4 #include <cmath>
5 #include <algorithm>
6 #include <stack>
7 #include <queue>
8 #include <vector>
9 #include <map>
10 #include <set>
11 #include <unordered_set>
12 #include <unordered_map>
13 #define ll long long
14 #define fi first
15 #define se second
16 #define pb push_back
17 #define me memset
18 const int N = 1e6 + 10;
19 const int mod = 1e9 + 7;
20 using namespace std;
21 typedef pair<int,int> PII;
22 typedef pair<long,long> PLL;
23
24 int t;
25 ll n,a[N],b[N],c[N];
26 ll sum;
27 ll ans=1e18+10;
28 int main() {
29 scanf("%d",&t);
30 while(t--){
31 scanf("%lld",&n);
32 ans=1e18+10;
33 sum=0;
34 for(int i=1;i<=n;++i){
35 scanf("%lld %lld",&a[i],&b[i]);
36 if(i>1) c[i]=max((ll)0,a[i]-b[i-1]);
37 }
38 c[1]=max((ll)0,a[1]-b[n]);
39 if(n==1){
40 printf("%lld\n",a[1]);
41 continue;
42 }
43 for(int i=1;i<=n;++i){
44 sum+=c[i];
45 }
46 for(int i=1;i<=n;++i){
47 ans=min(ans,a[i]+sum-c[i]);
48 }
49 printf("%lld\n",ans);
50 }
51
52 return 0;
53 }

Codeforces Educational Rounds 85 A~C的更多相关文章

  1. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

  2. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) E. Pencils and Boxes 题目连接: http://code ...

  3. Codeforces Educational Round 33 题解

    题目链接   Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> ...

  4. Codeforces Educational Round 92 赛后解题报告(A-G)

    Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...

  5. codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers

    题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...

  6. codeforces Educational Codeforces Round 16-E(DP)

    题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...

  7. Codeforces Educational Codeforces Round 15 E - Analysis of Pathes in Functional Graph

    E. Analysis of Pathes in Functional Graph time limit per test 2 seconds memory limit per test 512 me ...

  8. Codeforces Educational Codeforces Round 15 D. Road to Post Office

    D. Road to Post Office time limit per test 1 second memory limit per test 256 megabytes input standa ...

  9. Codeforces Educational Codeforces Round 15 C. Cellular Network

    C. Cellular Network time limit per test 3 seconds memory limit per test 256 megabytes input standard ...

随机推荐

  1. Shiro的认证与授权

    shiro实战教程 一.权限管理 1.1什么是权限管理 基本上涉及到用户参与的系统都需要进行权限管理,权限管理属于系统安全的范畴,权限管理实现对用户访问系统的控制,按照安全规则或者安全策略控制用户可以 ...

  2. Centos7安装RabbitMQ详细教程

    MQ引言 什么是MQ MQ:message Queue翻译为消息队列,通过典型的生产者和消费者模型不断向消息队列中生产消息,消费者不断从队列中获取消息.因为消息的生产和消费都是一部的,而且只关心消息的 ...

  3. 【Mysql】[Err] 1153 - Got a packet bigger than 'max_allowed_packet' bytes

    今天用Navicat导入的时候报错 [Err] 1153 - Got a packet bigger than 'max_allowed_packet' bytes 原因是数据库默认是16M的数据,这 ...

  4. ctfshow—web—web7

    打开靶机 发现是SQL注入,盲注 过滤了空格符,可以用/**/绕过,抓包 直接上脚本 import requestss=requests.session()url='https://46a0f98e- ...

  5. DOCKER 安装步骤-最靠谱的笔记

    一.系统环境规划 服务器名 项目名称 docker 操作系统 CentOS Linux release 7.1.1503 (Core) Docker 版本 17.03.2-ce   二.Docker ...

  6. Mybatis Plus 3.4版本之后分页插件的变化

    一.MybatisPlusInterceptor 从Mybatis Plus 3.4.0版本开始,不再使用旧版本的PaginationInterceptor ,而是使用MybatisPlusInter ...

  7. Python小度

    这只是一个对话器!还不能听歌(反正我也没在UNIT平台配置听歌的功能)! 反正最近也不知怎么的,就想做一个AI对话器语音识别和语音输出都不要,input()和print()就行本来准备用小爱的,但要实 ...

  8. centos系统磁盘扩容

    1.查看磁盘空间大小,使用df -h 命令. 2. 增加磁盘空间,例如下图使用VM虚拟机增加的方式.物理机直接安装挂载上去. 3. 使用fdisk /dev/sda, 创建新分区. 4.重启Linux ...

  9. WPF TabControl美化

    <Window.Resources> <!-- TabItem的样式 --> <Style TargetType="{x:Type TabItem}" ...

  10. 截屏转base64 调用栈

    房产经纪人页面错误信息采集方案 https://mp.weixin.qq.com/s/tznlHs3XRwJFQtGiCwp15w function captureScreen() {     var ...