Codeforces Round #206 (Div. 2)
只会做三个题;
A:简单题,不解释:
#include<cstdio>
using namespace std; int k,d; int main()
{
scanf("%d%d",&k,&d);
if(d==)
{
if(k>)puts("No solution");
else puts("");
}
else
{
if(k>=d)
{
for(int i=; i<d; i++)
printf("");
for(int i=; i<k-d; i++)
printf("");
}
else
{
printf("%d",d);
for(int i=; i<k; i++)
printf("");
}
}
return ;
}
B题:从第一种票的往第四种票用贪心扫一遍;
#include<cstdio>
#define maxn 1005
using namespace std; int n,m,c[],bus[maxn],trai[maxn],buspen[maxn];
int tailpen[maxn],sum1,sum2,ans; int main()
{
for(int i=; i<; i++)scanf("%d",&c[i]);
scanf("%d%d",&n,&m);
for(int i=; i<n; i++)
{
scanf("%d",&bus[i]);
if(bus[i]*c[]>c[])buspen[i]=c[];
else buspen[i]=bus[i]*c[];
}
for(int i=; i<m; i++)
{
scanf("%d",&trai[i]);
if(trai[i]*c[]>c[])tailpen[i]=c[];
else tailpen[i]=trai[i]*c[];
}
for(int i=;i<n;i++)sum1+=buspen[i];
for(int i=;i<m;i++)sum2+=tailpen[i];
if(sum1<c[])ans+=sum1;
else ans+=c[];
if(sum2<c[])ans+=sum2;
else ans+=c[];
if(ans<c[])printf("%d",ans);
else printf("%d",c[]);
}
C:
n件物品n+1个空,枚举他们最后相遇的那个空,然后贪心就可!
代码:
#include<cstdio>
#include<iostream>
#define maxn 100005
using namespace std; int n,l,r,ql,qr,v;
long long goods[maxn],s[maxn],ans;
int main()
{
scanf("%d%d%d%d%d",&n,&l,&r,&ql,&qr);
for(int i=; i<=n; i++)
{
scanf("%d",&goods[i]);
s[i]=s[i-]+goods[i];
}
long long minn=;
for(int i=;i<=n;i++)
{
v=n-i;
ans=s[i]*l+(s[n]-s[i])*r;
if (i>v+) ans+=(i-v-)*ql;
if (v>i+) ans+=(v-i-)*qr;
if (ans<minn) minn=ans;
}
cout<<minn;
}
Codeforces Round #206 (Div. 2)的更多相关文章
- 构造水题 Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
题目传送门 /* 构造水题:对于0的多个位数的NO,对于位数太大的在后面补0,在9×k的范围内的平均的原则 */ #include <cstdio> #include <algori ...
- Codeforces Round #206 (Div. 2) 部分题解
传送门:http://codeforces.com/contest/355 A:水题,特判0 int k,d; int main(){ //FIN; while(cin>>k>> ...
- Codeforces Round #206 (Div. 2) A. Vasya and Digital Root
#include <iostream> using namespace std; int main(){ int k,d; cin >> k >>d; ) { k ...
- Codeforces Round #206 (Div. 1)B(记忆化)
这题刚开始理解错题意了 以为只能往右和下走 这题挺好的 看题解看了N久啊 二维的DP 第一维表示走到第几步 可以画一个正方形 以左上角斜着划线 第i步走的点只能是第i条线上的点 而dp的第二维 就表示 ...
- 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 ...
随机推荐
- Android注解支持(Support Annotations)
注解支持(Support Annotations) Android support library从19.1版本开始引入了一个新的注解库,它包含很多有用的元注解,你能用它们修饰你的代码,帮助你发现bu ...
- SQL高级优化之经常使用的优化策略-2(The Return Of The King)
1.2 索引 索引不是越多越好,你须要知道索引建立多了.写入数据的效率会减少.怎样使用索引要看你的项目的应用场景,做出合理的測试评估. 1.2.1 统计数量 统计数量上.假设字段(fieldName) ...
- 24小时学通LINUX内核系列
http://www.cnblogs.com/lihuidashen/category/667475.html
- 基于VMware为CentOS 6.5配置两个网卡
为CentOS 6.5配置两块网卡,一块是eth0,一块是eth1,下面以master为例 1.选择“master”-->“编辑虚拟机设置”,如下所示 2.单击“添加”,如下 3.选择“网络适配 ...
- hdu2044java递推
一只小蜜蜂... Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Su ...
- iOS 网络编程:socket
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/c ...
- Task类(任务)
任务表示应完成的某个单元的工作.这个单元的工作可以在单独的线程中运行,也可以以同步方式启动一个任务,这需要等待主调用线程.使用任务不仅可以获得一个抽象层,还可以对底层线程进行很多控制. 1.启动任务 ...
- site与subsite
1.List template只能加载在主站点上,加载在主站点上之后,其subsite也能引用: 2.发布webpart的时候,路径也只能写网站集的路径,发布到网站集之后其主站点和subsite都能引 ...
- angularjs中异常处理
1.TypeError: Cannot read property '$valid' of undefined a. Add ng-submit attribute to the form: < ...
- 将decimal类型的数值后面的0和.号去掉
今天在群里面看到有朋友在问如下的需求,想到以前在写项目时也遇到这种处理数值的需求,所以写一个例子贴在博客里. 需求:在许多显示货币值时,可能需要截取掉后面的0,显示小数值或者整型值. 举例:(1)数据 ...