Codeforces Educational Rounds 85 A~C
题意:统计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 }
题意:定义每人拥有的钱不小于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 }
题意:有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的更多相关文章
- 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 ...
- 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 ...
- Codeforces Educational Round 33 题解
题目链接 Codeforces Educational Round 33 Problem A 按照题目模拟,中间发现不对就直接输出NO. #include <bits/stdc++.h> ...
- Codeforces Educational Round 92 赛后解题报告(A-G)
Codeforces Educational Round 92 赛后解题报告 惨 huayucaiji 惨 A. LCM Problem 赛前:A题嘛,总归简单的咯 赛后:A题这种**题居然想了20m ...
- codeforces Educational Codeforces Round 5 A. Comparing Two Long Integers
题目链接:http://codeforces.com/problemset/problem/616/A 题目意思:顾名思义,就是比较两个长度不超过 1e6 的字符串的大小 模拟即可.提供两个版本,数组 ...
- codeforces Educational Codeforces Round 16-E(DP)
题目链接:http://codeforces.com/contest/710/problem/E 题意:开始文本为空,可以选择话费时间x输入或删除一个字符,也可以选择复制并粘贴一串字符(即长度变为两倍 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- selenium爬虫 | 爬取疫情实时动态(二)
'''@author:Billie更新说明:1-28 17:00 项目开始着手,spider方法抓取到第一条疫情数据,save_data_csv方法将疫情数据保存至csv文件1-29 13:12 目标 ...
- dd命令的详细介绍
1.命令简介 dd 的主要选项: 指定数字的地方若以下列字符结尾乘以相应的数字: b=512, c=1, k=1024, w=2, xm=number m if=file #输入文件名,缺省为标准输 ...
- MybatisPlus多数据源及事务解决思路
关于多数据源解决方案 目前在SpringBoot框架基础上多数据源的解决方案大多手动创建多个DataSource,后续方案有三: 继承org.springframework.jdbc.datasour ...
- Windows安全加固
Windows安全加固 # 账户管理和认证授权 # 1.1 账户 # 默认账户安全 # 禁用Guest账户. 禁用或删除其他无用账户(建议先禁用账户三个月,待确认没有问题后删除.) 操作步骤 本地用户 ...
- QT串口助手(二):参数配置
作者:zzssdd2 E-mail:zzssdd2@foxmail.com 一.前言 主要实现功能 串口参数的配置:波特率.数据位.停止位.校验位 本机串口设备的查询与添加显示 串口设备的手动更新与打 ...
- jenkins Windows下自动化部署.netcore
(1) 安装java-sdk (Jdk5-11)不用配置环境变量 https://www.oracle.com/java/technologies/javase/javase-jdk8-downloa ...
- 在EXCEL中如何同时冻结行与列?
鼠标所在的单元格的位置 ,决定了你冻结的行和列.如: 冻结第一行与第一列, 只需要将鼠标置于单元格在第二列,第二行. 点击冻结
- .NET Core 问题记录
前言: 最近在项目中遇到了遇到了写部署步骤过多的问题,为了减少.net core项目部署步骤:需要对一些基础问题进行验证: 如端口设置.单页应用程序(angluar)合并部署方式等相关问题,特将解决过 ...
- 【Python】中国有哪些同名的省市县?
这道题适合写个脚本来解. 首先从百度地图API下载一份行政区划数据. 开发资源 | 百度地图API SDK 然后做一个简单的数据统计就可以啦~ 行政区划同一级同名的: import pandas as ...
- 精通MySQL之架构篇
老刘是即将找工作的研究生,自学大数据开发,一路走来,感慨颇深,网上大数据的资料良莠不齐,于是想写一份详细的大数据开发指南.这份指南把大数据的[基础知识][框架分析][源码理解]都用自己的话描述出来,让 ...