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 ...
随机推荐
- Log4j配置按照文件大小和日期分割日志文件
目录 Log4j 下载地址 文件大小分割日志文件 以日期分割每天产生一个日志文件 自定义信息输出到日志文件 Log4j 下载地址 Log4j是Apache的一个开源项目,通过使用Log4j,我们可以控 ...
- awk -v参数
-v var=val --assign var=val Assign the value val to the variable var, before execution of the progra ...
- 【ASM】查看ASM磁盘组剩余容量和总容量
col total_size for a10; col free_size for a20; select name,total_mb/1024 || 'G' as total_size , free ...
- SpringBoot快速掌握(1):核心技术
SpringBoot快速掌握(1):核心技术 SpringBoot快速掌握(1):核心技术 SpringBoot快速掌握(1):核心技术 SpringBoot快速掌握(1):核心技术 SpringBo ...
- Java并发包源码学习系列:JDK1.8的ConcurrentHashMap源码解析
目录 为什么要使用ConcurrentHashMap? ConcurrentHashMap的结构特点 Java8之前 Java8之后 基本常量 重要成员变量 构造方法 tableSizeFor put ...
- 無法直接連接互聯網,需要使用代理時(Scrapy)
在windows系統中,如果無法直接連接互聯網,需要使用代理時該怎麽做呢? 1. 在powershell中設置proxy 背景:使用公司電腦,無法直接訪問互聯網,想要訪問互聯網就得使用代理,但是在控制 ...
- (001)每日SQL学习:关于UNION的使用
union内部必须有相同的列或者相同的数据类型,同时,每条 SELECT 语句中的列的顺序必须相同.union合并了select的结果集. union 与union all的不同: union合并了重 ...
- spring 之7种重要设计模式
Spring中涉及的设计模式总结 1.简单工厂(非23种设计模式中的一种) 实现方式: BeanFactory.Spring中的BeanFactory就是简单工厂模式的体现,根据传入一个唯一的标识来获 ...
- is == id ,编码
一. id 查询内存地址. # name = 'alex' # print(id(name)) # name1 = 'alex' # name2 = 'alex' # print(name1 == n ...
- [JSOI2019]节日庆典 做题心得
[JSOI2019]节日庆典 做题心得 一个性质有趣的字符串题 这要是在考场上我肯定做不出来吧 一开始还以为要 SAM 什么的暴力搞,没想到只用到了 \(Z\) 函数 -- 也是我生疏了罢 (学了啥忘 ...