难得一次比赛能够自己成功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)的更多相关文章

  1. Codeforces Round #211 (Div. 2) D题(二分,贪心)解题报告

    ---恢复内容开始--- 题目地址 简要题意: n个小伙子一起去买自行车,他们有每个人都带了一些钱,并且有公有的一笔梦想启动资金,可以分配给任何小伙子任何数值,当然分配权在我们的手中.现在给出m辆自行 ...

  2. Codeforces Round #211 (Div. 2)-D. Renting Bikes,二分!感谢队友出思路!

    D. Renting Bikes 读懂题后一开始和队友都以为是贪心.可是贪心又怎么贪呢..我们无法确定到底能买多少车但肯定是最便宜的前x辆.除了公共预算每个人的钱只能自己用,也无法确定每个人买哪一辆车 ...

  3. 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 ...

  4. 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 ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. 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 ...

随机推荐

  1. 关于git的cherry-pick命令

    $ git cherrypick 用一条新的指令-----拣选指令(git cherry-pick) 实现提交在新的分支上"重放", 拣选指令----git cherry-pick ...

  2. MSP430矩阵及独立键盘

    在学习MSP430的时候,总是有很多东西记不住,同时又是英文的资料,好多东西也是没怎么看透,英文虽过六级但是看英文资料还是有一种想睡的冲动啊,在学习键盘的时候,我的这块板子有些不同,矩阵键盘和独立键盘 ...

  3. h2database源码浅析:锁与MVCC

    Table Level Locking The database allows multiple concurrent connections to the same database. To mak ...

  4. linux shell if参数

    shell 编程中使用到得if语句内判断参数 –b 当file存在并且是块文件时返回真 -c 当file存在并且是字符文件时返回真 -d 当pathname存在并且是一个目录时返回真 -e 当path ...

  5. post 提交数据

    1 默认:application/x-www-form-urlencoded 在网页表单中可设置 enctype的值,如果不设,默认是 application/x-www-form-urlencode ...

  6. 使用FOR循环语句在屏幕上输出一个由星号组成的直角三角形

    题目要求: 请用C++的信息输出方式,使用循环语句在屏幕上输出一个由星号组成的直角三角形,形状如下: * ** *** **** ***** 要求: 完全使用C++的信息输出方式,即cout以及流插入 ...

  7. Java获取方法参数名、Spring SpEL解析

    @Test public void testParse() { //表达式解析 ExpressionParser expressionParser = new SpelExpressionParser ...

  8. 暑假集训(2)第七弹 -----今年暑假不AC(hdu2037)

    J - 今年暑假不AC Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:32768KB     64 ...

  9. 不同的extend 在调用构造函数时不同的写法

     /**  * jQuery.hhNewSilder 滚动图片插件  * User: huanhuan  * QQ: 651471385  * Email: th.wanghuan@gmail.com ...

  10. Linux性能监控的几个工具(转)

    转载于:http://blog.csdn.net/tianlesoftware/article/details/6198780 Linux系能监控主要涉及系统4个方面资源的监控: CPU Memory ...