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. C中的dll 、lib和exe文件

    参考:链接1   链接2 DLL 动态链接库(Dynamic Link Library,缩写为DLL),运行时加载是一个可以被其它应用程序共享的程序模块,其中封装了一些可以被共享的例程和资源.动态链接 ...

  2. 如何实现一个简易版的 Spring - 如何实现 Constructor 注入

    前言 本文是「如何实现一个简易版的 Spring」系列的第二篇,在 第一篇 介绍了如何实现一个基于 XML 的简单 Setter 注入,这篇来看看要如何去实现一个简单的 Constructor 注入功 ...

  3. python常见题型

    语言特性 1. 谈谈对 Python 和其他语言的区别 2. 简述解释型和编译型编程语言 3. Python 的解释器种类以及相关特点? 4. Python3 和 Python2 的区别? 5. Py ...

  4. 【函数分享】每日PHP函数分享(2021-1-19)

    substr 函数返回字符串的一部分.注释:如果 start 参数是负数且 length 小于或等于 start,则 length 为 0. string substr (string $string ...

  5. 【Linux】ssh互信脚本

    使用互信脚本的时候,需要敲回车,但是shell脚本无法满足,所以需要用到expect脚本 rpm -qa | grep expect 如果没有的话,直接用yum安装即可 yum install exp ...

  6. GitLab-CI/CD入门实操

    以Spring boot项目为例.传统方式是本地生成jar包,FTP上传服务器,重启服务:如果是内网测试服,也可以在服务器上安装git,在服务器上编译打包.但这都需要人为干预,于是CI/CD就出现了. ...

  7. 【转】Js中的window.parent ,window.top,window.self 详解

    [转自]http://blog.csdn.net/zdwzzu2006/article/details/6047632 在应用有frameset或者iframe的页面时,parent是父窗口,top是 ...

  8. javascript判断浏览器访问,刷新,返回

    话不多说,直接上 if (window.performance.navigation.type === 0/* 正常访问 */) { // 你要干的事 } else if (window.perfor ...

  9. 华为交换机telnet登录时老是提醒是否更改初始密码- Warning: The initial password poses security risks

    问题:华为交换机在Telnet登录的时候总是提示初始密码不安全需要修改密码的处理方法 Warning: The initial password poses security risks   如果你输 ...

  10. Mac 禁用动画

    # opening and closing windows and popovers defaults write -g NSAutomaticWindowAnimationsEnabled -boo ...