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. git文件操作

    git下载地址: https://git-scm.com/download mac 直接使用brew下载brew install git 1Git一般工作流程: 1.在工作目录创建版本库 2.在工作目 ...

  2. 【Zabbix】配置zabbix agent向多个server发送数据

    1.背景: server端: 172.16.59.197  ,172.16.59.98 agent 端: hostname:dba-test-hzj02 IP:172.16.59.98 2.方式: 配 ...

  3. OpenID协议

    背景 当我们要使用一个网站的功能时,一般都需要注册想用的账号.现在的互联网应用很多,一段时间之后你会发现你注册了一堆账号密码,根本记不住. 你可能会想到所有的网站都用同一套用户名和密码,这样虽然能解决 ...

  4. MAVEN编译NIFI源码

    场景: 由于项目需求,需要借用NIFI进行二次开发,因此需要将NIFI源码进行修改,然后编译,办公环境无外网. 步骤: (1)   找一台可以上网(外网)的机器,安装java环境和maven环境,安装 ...

  5. VB基础总结

    前段时间用VB写了一个简单窗口小应用,久了不碰VB,都忘了,下面用思维导图简单总结了一些基础的东西,方便以后快速查阅.

  6. MyBatis初级实战之四:druid多数据源

    欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...

  7. linux下安装nacos

    一.安装 1.下载安装包: https://github.com/alibaba/nacos/releases 2.解压 : tar -xzvf nacos-server-1.2.1.tar.gz 3 ...

  8. Linux下nginx的安装以及环境配置

    参考链接 https://blog.csdn.net/qq_42815754/article/details/82980326 环境: centos7 .nginx-1.9.14 1.下载 并解压  ...

  9. 使用 gitlab-runner 持续集成

    gitlab-runner 是 Gitlab 推出的与 Gitlab CI 配合使用的持续集成工具.当开发人员在 Gitlab 上更新代码之后,Gitlab CI 服务能够检测到代码更新,此时可以触发 ...

  10. C#高级编程第11版 - 第六章 索引

    [1]6.2 运算符 1.&符在C#里是逻辑与运算.管道符号|在C#里则是逻辑或运算.%运算符用来返回除法运算的余数,因此当x=7时,x%5的值将是2. [2]6.2.1 运算符的简写 1.下 ...