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 ...
随机推荐
- 【Slickflow学习】.NET开源工作流项目转换(二)
第一次自己写博客文章,大家多多指教.写博客主要记录一下学习的过程,给初学者提供下参考,也留给自己做备忘. Slickflow .NET开源工作流-项目转换 上一篇文章里说了1.2版本的下载,下载解压后 ...
- jquery自动生成二维码
把下面的jquery代码放到想要在当前页面上面生成二维码: 代码如下: <script type="text/javascript">var _qrContent='' ...
- jQuery 黑白插件
1 add jQuery and plug in to the page <script src="js/jquery.min.js"></script> ...
- Python(2.7.6) ConfigParser - 读写配置文件
Python 标准库的 ConfigParser 模块提供一套 API 来读取和操作配置文件. 配置文件的格式 a) 配置文件中包含一个或多个 section, 每个 section 有自己的 opt ...
- hdoj1285 拓扑排序
题目链接 分析: 很明显,一看就是拓扑排序. 看似简单, 暗藏武器啊. 第一次做的时候一边拓扑排序一边标记他们的深度, 例如题中给的例子 {1 2:2 3:4 3 }.1的深度为1. 2.4的深度为2 ...
- android显示手机电量
package com.basillee.asus.demo; import android.app.Notification; import android.content.BroadcastRec ...
- openvswitch安装和使用 --修订通用教程的一些错误
1.下载openvswitch源文件,注意版本要适合操作系统内核. 推荐openvswitch2.0及其以上版本. 2.开始安装openvswitch cd openvswitch sudo ./bo ...
- MySQL备份方案
下面将分别模拟不同场景数据库宕机解决方案:这里应用到的技术分别为innobackuper及binlog日志来进入还原数据 一.主从库情况下(为了不影响主库的性能,备份都放在从库上进行)当主库宕机时,如 ...
- 动易标签函数position() 应用
Position()返回当前正在被处理的节点的 index 位置.例子://book[position()<=3].结果:选择前三个 book 元素当然在动易标签中,我们不需要这样用,因为用sq ...
- sql2008存储过程解密。
今天有一个同事在做一个项目的时候,因为现在公司不跟某一家公司合作.有一些sql的存储过程是加密,现在想打开那些存储过程来解密.故查看了一些资料终于解密成功.步骤如下: 1.需要开始DAC连接. 1.1 ...