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”三种中任意一种就输 ...
随机推荐
- web Servlet 3.0 新特性之web模块化编程,web-fragment.xml编写及打jar包
web Servlet 3.0 模块化 原本一个web应用的任何配置都需要在web.xml中进行,因此会使得web.xml变得很混乱,而且灵活性差,因此Servlet 3.0可以将每个Servlet. ...
- sql 服务器链接远程 sql 服务器 脚本
exec sp_droplinkedsrvlogin 'test',null exec sp_dropserver 'test' exec sp_addlinkedserver@server='Tes ...
- sqlserver2008自动备份,自动删除较早的别分文件
1.自动备份数据库 完成时候可以在维护计划中看到这个计划任务(xxxback),同事在作业里面会有个类似名称的作业(sql代理要启动,才能自动执行). 2.自动删除较早的备份文件 邮件选择上面的维护计 ...
- nginx 413文件上报太大
在nginx使用过程中,上传文件的过程中,通常需要设置nginx报文大小限制.避免出现413 Request Entity Too Large. 于是奇葩的问题被我们遇到了,详细配置请参考下面.我们的 ...
- .net操作xml文件(新增.修改,删除,读取) 转
今天有个需求需要操作xml节点.突然见遗忘了许多.上网看了些资料.才整出来.脑袋真不够用.在这里把我找到的资料共享一下.方便以后使用.本文属于网摘/ 1 一.简单介绍2 using System.Xm ...
- XDU 1011
解法1:TLE #include<stdio.h> int main() { long long n; //freopen("in.txt","r" ...
- iClap专访:颠覆传统办公方式,规范化产品管理系统
背景:DevStore是成立于2014年的移动互联网企业运营解决方案整合平台,线上资源涉及产品研发,设计,推广运维各个阶段,致力于为互联网从业者提供帮助.iClap是DevStore的全新产品,于20 ...
- getAttribute() 与 attr() 的区别
getAttribute() 和 attr() 都是获取元素属性的方法,只是一种是 JS 写法,一种是 JQ 写法,但其实它们是有区别的. 主要区别 调用 getAttribute() 的主体必须是元 ...
- mysql-connector-java小笔记
Java 连接MySQL需要驱动包,否则JDBC无法访问数据库(无法注册驱动),常用的是mysql-connector-java,在idea中新建项目时可以在选择依赖时勾选Mysql,这样就会自动加载 ...
- Docker storage drivers
因为Docker的镜像是分层的,包含只读层和可读写层,因此选择正确的Storage Driver对于容器的性能是非常重要的. 支持的Linux发行版本 目前推荐使用性能最好的Overlay2.RHEL ...