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 ...
随机推荐
- Linux安装后的系统配置
第一步: Linux系统安装之后,可以设置系统的日期和时间.给系统添加用户.安装软件.在Red Hat网络中注册机器以及完成其他任务.设置代理将允许用户从一开始就配置环境,从 而使用户能够快速地开始使 ...
- UVA 11021 - Tribles(概率)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=481&page=s ...
- systemverilog interface
普通的模块使用法:注意我们这里只实现了部分功能....不是完全的读写模块.... module mem_core( input logic wen, input logic ren, ...
- JavaScript高级程序设计(三):基本概念:数据类型
特别注意:ECMAScript是区分大小写的. 一.变量 1.ECMAScript的变量是松散型的.所谓松散型就是可以用来保存任何类型的数据.即每个变量仅仅是一个用于保存值的占位符而已.定义变量时要使 ...
- About 'atoi'
在很多地方我们看到的都是:atoi 是一个 C Reference function atoi() convert a string to an integer. This function of s ...
- HowTo: SVN undo add without reverting local changes
Reference: http://stackoverflow.com/questions/5083242/undo-svn-add-without-reverting-local-edits svn ...
- 由Double类型数据到数据的格式化包java.text
需求:Double类型数据截取操作保留两位小数 解决方案: java.text.DecimalFormat df =new java.text.DecimalFormat("#.00&quo ...
- Web前端新人笔记之CSS字体
本章内容是阅读CSS权威指南的一个小积累和随笔.新人必看,老鸟也可查看并指出不足指出以便后人阅读更好地理解.O(∩_∩)O谢谢!!!设置字体属性时样式变的最常见的用途之一:不过,尽管字体选择很重要,但 ...
- quality center的使用简介
quality center是一个基于Web的测试管理工具,其实是伪B/S的软件,可以组织和管理应用程序测试流程的所有阶段,包括制定测试需求.计划测试.执行测试和跟踪缺陷.此外,通过Quality C ...
- SQL Server2008数据库导入导出兼容性处理
使用场景:SQL Server 的高版本数据库恢复到低版本则可能会有兼容性问题,为了解决此类问题进行数据库脚本模式处理,数据库结构,及数据存储更换版本等. 1. 选择要导出的数据库,右键任务,生成脚 ...