难得一次比赛能够自己成功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. CountDownLatch(闭锁)

    一.闭锁(Latch)    闭锁(Latch):一种同步方法,可以延迟线程的进度直到线程到达某个终点状态.通俗的讲就是,一个闭锁相当于一扇大门,在大门打开之前所有线程都被阻断,一旦大门打开所有线程都 ...

  2. PHP中foreach循环详解

    首先要说的是,其实我对foreach循环的用法并不是很精通,说详解,其实也只是我自己的理解,希望对你能有点帮助 . 先来看一下foreach的语法: foreach ($array as $key=& ...

  3. BSP模型

    http://www.uml.org.cn/yunjisuan/201212191.asp Hama中最关键的就是BSP(Bulk Synchronous Parallel-"大型" ...

  4. scala学习笔记:无参函数

    scala> def repeat(times:Int)(run:()=>Unit)=for(i<-1 to times)run() repeat: (times: Int)(run ...

  5. .net 并发

    Nhibernate并发参考 http://www.cnblogs.com/lyj/archive/2008/10/21/1316269.html EF并发参考 http://www.cnblogs. ...

  6. HW--漂亮度2(测试通过)

    总结:几个函数的使用 (1)  int num=Integer.parseInt(str[0]); //将第一个字符串转成整形数,表示名字个数 (2) String string1=str[i].to ...

  7. ###Git使用问题

    #@date: 2014-05-04 #@author: gerui #@email: forgerui@gmail.com 一.git reset的使用 今天修改了代码,就git add ./,添加 ...

  8. 杂技之sharpdevelop调试aps.net

    背景: 本人笔记本电脑不给力,vs打开实在太慢,因此考虑使用sharpdevelop,但sharpdevelop有点麻烦事,就是不支持asp.net的调试,为解决此问题,本人在此杂技一把了 方案一: ...

  9. ios专题 - objc runtime 动态增加属性

    objective-c中,有类别可以在不修改源码的基础上增加方法:近排在看别人的开源代码时,发现还可以动态增加属性.而且是在运行时,太牛B了. 使用运行时库,必须要先引入 objc/runtime.h ...

  10. myeclipse 右键 Add Struts... 页面报404 错误

    网上试了很多种方法都不对,结果老师两下点出来了 我的改正方法是: 将WebRoot/WEB-INF/web.xml中的 <url-pattern>/*</url-pattern> ...