Codeforces Round #211 (Div. 2)
难得一次比赛能够自己成功A掉四个题;
A题:水题,模拟一下就行;
#include <iostream>
#include <cstdio>
using namespace std; void print(int x)
{
if(x>=){printf("-O|");x%=;}
else printf("O-|");
if(x==)puts("-OOOO");
else if(x==)puts("O-OOO");
else if(x==)puts("OO-OO");
else if(x==)puts("OOO-O");
else if(x==)puts("OOOO-");
} int n;
int main()
{
scanf("%d",&n);
while(n/>)
{
int x=n%;
print(x);
n/=;
}
print(n);
return ;
}
B:水题,边输入边统计就行:
By yours1103, contest: Codeforces Round # (Div. ), problem: (B) Fence, Accepted, #
#include <iostream>
#include <cstdio>
#define maxn 150005
using namespace std; int n,k,ans,num[maxn],tt,mi;
int main()
{
scanf("%d%d",&n,&k);
tt=k-;
for(int i=; i<n; i++)
{
if(i<k)
{
scanf("%d",&num[i]);
ans+=num[i];
mi=ans;
}
else
{
scanf("%d",&num[i]);
ans+=num[i]-num[i-k];
if(ans<mi)
{
tt=i;
mi=ans;
}
}
}
printf("%d",tt-k+);
return ;
}
C:水题,对于连续的数量大于1的字符,最好的情况是212121····
#include<cstdio>
#include<cstring>
#define maxn 200009
using namespace std; char s[maxn],t[maxn];
int co[maxn];
int cnt,num; int main()
{
scanf("%s",s);
int l=strlen(s);
t[cnt]=s[];
num=;
for(int i=;i<l;i++)
{
if(s[i]!=s[i-])
{
co[cnt++]=num;
num=;
t[cnt]=s[i];
}
else num++;
}
co[cnt++]=num;
int in=-;
co[cnt]=;
for(int i=;i<=cnt;i++)
{
if(co[i]==)
{
int dd=;
for(int j=in+;j<i;j++)
{
co[j]=-dd;
dd=-dd;
}
in=i;
}
}
for(int i=;i<cnt;i++)
{
while(co[i]--)putchar(t[i]);
}
return ;
}
D:二分+贪心的题。挺简单的
#include<cstdio>
#include<algorithm>
#include<cstring>
#define maxn 100005
using namespace std; int p[maxn],v[maxn],a;
int n,m;
bool vis[maxn];
bool ok(int x)
{
int tmp=a;
int cnt=;
memset(vis,,sizeof vis);
for(int i=x-;i>=;i--)
{
if(p[n-cnt]<v[i])tmp-=(v[i]-p[n-cnt]);
cnt++;
if(tmp<)return ;
}
return ;
} int main()
{
scanf("%d%d%d",&n,&m,&a);
for(int i=;i<n;i++)
scanf("%d",&p[i]);
for(int i=;i<m;i++)
scanf("%d",&v[i]);
sort(v,v+m);
sort(p,p+n);
int l=,r=min(m,n);
while(l<=r)
{
int mid=(l+r)>>;
if(ok(mid))l=mid+;
else r=mid-;
}
int sum=,tt;
for(int i=;i<r;i++)
sum+=v[i];
if(sum>a)tt=sum-a;
else tt=;
printf("%d %d\n",r,tt);
return ;
}
Codeforces Round #211 (Div. 2)的更多相关文章
- Codeforces Round #211 (Div. 2) D题(二分,贪心)解题报告
---恢复内容开始--- 题目地址 简要题意: n个小伙子一起去买自行车,他们有每个人都带了一些钱,并且有公有的一笔梦想启动资金,可以分配给任何小伙子任何数值,当然分配权在我们的手中.现在给出m辆自行 ...
- Codeforces Round #211 (Div. 2)-D. Renting Bikes,二分!感谢队友出思路!
D. Renting Bikes 读懂题后一开始和队友都以为是贪心.可是贪心又怎么贪呢..我们无法确定到底能买多少车但肯定是最便宜的前x辆.除了公共预算每个人的钱只能自己用,也无法确定每个人买哪一辆车 ...
- Codeforces Round #211 (Div. 2)B. Fence
B. Fence time limit per test 1 second memory limit per test 256 megabytes input standard input outpu ...
- 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”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
随机推荐
- 关于Eclipse插件开发-----加入首选项(preferencePages)
选择主菜单"窗口---->首选项"命令打开"首选项"窗口.此窗口是Eclipse设置项的集中营, 修改plugin.xml文件,设置首选项的扩展点: pl ...
- 史上最全的phpstorm常用配置
取消自动保存并标识修改的文件为星星标记 1.取消自动保存 进入 File -> Settings -> General,取消下面两选项的勾选: 2.星星标记 进入 File -> S ...
- Activti跳过中间节点的helloworld实例程序
http://blog.csdn.net/songzheng_741/article/details/17289633 此实例是一个最简单的在运行时人为动态改变流程运转的实例,意在为任意流.驳回等功能 ...
- 通过GitHub部署网站到Azure WebSite
一.将代码上传到GitHub存储库中 第一步:创建Github新账户 第二步:新建仓库 第三步:安装Github shell程序,地址:http://windows.github.com/ 第四步:打 ...
- Android开发之BroadcastReceiver
BroadcastReceiver:广播接收者.用来接收系统或应用中的广播. 在Android系统中,广播体现在方方面面,例如当开机完成后系统会产生一条广播,接收到这条广播就能实现开机启动服务的功能: ...
- ios registerNib: and registerClass:
先看看apple官网简述: registerNib:forCellWithReuseIdentifier: Register a nib file for use in creating new co ...
- 处理不等高TableViewCell
课题一:如何计算Cell高度 方案一:直接法(面向对象) 想知道妹纸爱你有多深?直接去问妹纸本人吧! 嗯!Cell也是一样的,想知道cell到底有多高?直接问Cell本人就好了.直接法,就是把数据布局 ...
- activemq spring 配置
Apache ActiveMQ是最流行和最强大的开源消息集成模式服务器.Apache ActiveMQ是速度快,支持多跨语言的客户端和协议,带有易于使用企业集成模式和许多先进的功能在充分支持JMS 1 ...
- 暑假集训(3)第四弹 -----Frogger(Poj2253)
题意梗概:青蛙王子最近喜欢上了另一只经常坐在荷叶上的青蛙公主.不过这件事不小心走漏了风声,被某fff团团员知 道了,在青蛙王子准备倾述心意的那一天,fff团团员向湖泊中注入大量的充满诅咒力量的溶液.这 ...
- config spec
config_spec Rules for selecting versions of elements to appear in a view APPLICABILITY Product Comma ...