Codeforces Round #202 (Div. 2)
第一题水题但是wa了一发,排队记录下收到的25,50,100,看能不能找零,要注意100可以找25*3
复杂度O(n)
第二题贪心,先找出最小的花费,然后就能得出最长的位数,然后循环对每个位上的数看能不能加上剩余的油漆比现在这数大,输出即可
复杂度O(10n)
By , contest: Codeforces Round # (Div. ), problem: (B) Color the Fence, Accepted, #
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
int n,minn=N,id;
cin>>n;
for(int i=;i<;i++)
{
cin>>a[i];
if(minn>=a[i])
{
minn=a[i];
id=i;
}
}
if(minn>n)
{
cout<<-<<endl;
return ;
}
int le=n%minn;
for(int i=;i<=(n-n%minn)/minn;i++)
{
int maxx=id;
if(le==)
{
cout<<id;
continue;
}
for(int j=;j<;j++)
if(le+minn>=a[j]&&j>maxx)
maxx=max(maxx,j);
cout<<maxx;
le-=(a[maxx]-minn);
}
cout<<endl;
return ;
}
b题
第三题推公式,一个多小时还是没做出来
Let the answer be x games. Notice that max(a1, a2, …, an) ≤ x. Then i-th player can be game supervisor in x–ai games. If we sum up we get
— it's the number of games in which players are ready to be supervisor. This number must be greater or equal to x — our answer.




Don't forget about that condition: max(a1, a2, …, an) ≤ x.
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<vector>
#include<cstdio>
#include<iomanip>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define pi acos(-1)
#define ll long long
#define mod 1000000007
#define ls l,m,rt<<1
#define rs m+1,r,rt<<1|1
#define MIN(a,b) a<b ? a:b using namespace std; const double g=10.0,eps=1e-;
const int N=+,maxn=+,inf=0x3f3f3f; ll a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie();
ll n,maxx=-,sum=;
cin>>n;
for(int i=;i<n;i++)
{
cin>>a[i];
sum+=a[i];
maxx=max(maxx,a[i]);
}
ll ans=maxx;
if(sum%(n-)==)cout<<max(sum/(n-),maxx)<<endl;
else cout<<max(sum/(n-)+,maxx)<<endl;
return ;
}
C
D,E现在水平不够,先放着
Codeforces Round #202 (Div. 2)的更多相关文章
- Codeforces Round #202 (Div. 1) A. Mafia 贪心
A. Mafia Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/348/problem/A D ...
- Codeforces Round #202 (Div. 1) A. Mafia 推公式 + 二分答案
http://codeforces.com/problemset/problem/348/A A. Mafia time limit per test 2 seconds memory limit p ...
- Codeforces Round #202 (Div. 1) D. Turtles DP
D. Turtles Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/problem/B ...
- Codeforces Round #202 (Div. 2) B,C,D,E
贪心 B. Color the Fence time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- Codeforces Round #202 (Div. 2) A,B
A. Cinema Line time limit per test 2 seconds memory limit per test 256 megabytes input standard inpu ...
- Codeforces Round #633 (Div. 2)
Codeforces Round #633(Div.2) \(A.Filling\ Diamonds\) 答案就是构成的六边形数量+1 //#pragma GCC optimize("O3& ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- Wilcoxon符号秩+秩和检验学习[转载]
参数检验就是已知数据的精确分布模型,根据数据来求出模型中的未知参数:而非参数检验就是无需对样本总体分布(比如满足正态分布)做出假设. 1.符号检验 转自:https://baike.baidu.com ...
- python select poll
http://www.cnblogs.com/coser/archive/2012/01/06/2315216.html
- C#:对含有中文的字符串进行MD5加密
MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider(); var Sign = BitConverter.ToString(MD5. ...
- XDU 1037 倍流畅序列(字符串匹配+贪心)
题目描述 对于一个0,1串s, 从左端开始读取它的0获得序列s0,从右端开始读取它的1获得s1,如果s0与s1同构,则称s为倍流畅序列.例如:011001是一个倍流畅序列, 因为:s0 = 0__00 ...
- ElasticSearch recovery过程源码分析
[ES版本] 5.5.0 [分析过程] 找到Recovery有6种状态 public class RecoveryState implements ToXContent, Streamable { p ...
- WPS宏不可用解决方法
在使用WPS Office过程中,遇见宏不可用,在启用宏的过程中提示获取VBA插件 解决方法: 1.下载VBA插件,下载地址:https://pan.baidu.com/s/1LqBmXw37U0km ...
- pigeon 介绍
https://github.com/dianping/pigeon Pigeon开发指南 Pigeon是一个分布式服务通信框架(RPC),在美团点评内部广泛使用,是美团点评最基础的底层框架之一. 主 ...
- Django学习笔记之Cookie、Session和自定义分页
cookie Cookie的由来 大家都知道HTTP协议是无状态的. 无状态的意思是每次请求都是独立的,它的执行情况和结果与前面的请求和之后的请求都无直接关系,它不会受前面的请求响应情况直接影响,也不 ...
- Yahoo网站性能优化的34条规则
摘自:http://blog.chinaunix.net/uid/20714478/cid-74195-list-1.html Yahoo网站性能优化的34条规则 1.尽量减少HTTP请求次数 终端用 ...
- Session管理之超时设置和强制下线
关于Session,在Java Web开发中,为我们提供了很多方便,Session是由浏览器和服务器之间维护的.好吧,闲话不多说,下面让我们一步一步来实现它们. (一)首先来说下Session超时时间 ...