A - Dima and Continuous Line

水题:直接模拟;

 #include<cstdio>
#define maxn 1005
using namespace std;
int x[maxn],y[maxn];
int main()
{
int n,a,b,last;
scanf("%d",&n);
bool flag=;
for(int i=;i<n;i++)
{
scanf("%d",&b);
a=last;
last=b;
if(i==)continue;
if(a>b)
{
a=a^b;
b=a^b;
a=a^b;
}
if(flag)
for(int j=;j<i;j++)
{
if((a>x[j]&&a<y[j]&&b>y[j])||(x[j]>a&&b>x[j]&&y[j]>b))
flag=;
}
x[i]=a;
y[i]=b;
}
if(flag==)puts("yes");
else puts("no");
return ;
}

B - Dima and Text Messages

水题:按照顺序找就行了

 #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#define maxn 100005
using namespace std;
string s,t,c;
int main()
{
int n;
scanf("%d",&n);
s="<3";
for(int i=;i<n;i++)
{
cin>>c;
s+=c;
s+="<3";
}
cin>>t;
int j=;
int l=s.size();
int m=t.size();
for(int i=;i<m;i++)
{
if(s[j]==t[i])
{
j++;
if(j==l)break;
}
}
if(j==l)puts("yes");
else puts("no");
return ;
}

C - Dima and Containers

水题:直接模拟,三个容器每个放一个大的,其他小的都放在deck的另一边;

 #include<cstdio>
#include<algorithm>
#define maxn 100005
using namespace std; struct node
{
int id;
int num;
bool operator<(const node &t)const
{
return num<t.num;
}
}no[maxn]; int ans[maxn]; char s[][]={"pushStack","pushQueue","pushFront","pushBack","","popStack","popStack popQueue","popStack popQueue popFront"};
int main()
{
int n;
scanf("%d",&n);
for(int i=;i<n;i++)
{
scanf("%d",&no[i].num);
no[i].id=i;
}
int j=;
for(int i=;i<n;i++)
{
if(no[i].num==&&i!=j)
{
int cnt=;
sort(no+j,no+i);
// for(int k=j;k<=i-1;k++)
// printf("%d<\n",no[k].num);
ans[no[i-].id]=;
cnt++;
if(i->=j){ans[no[i-].id]=;cnt++;}
if(i->=j){ans[no[i-].id]=;cnt++;}
if(i->=j)
{
for(int k=j;k<=i-;k++)
ans[no[k].id]=;
}
if(cnt==)ans[i]=;
if(cnt==)ans[i]=;
if(cnt==)ans[i]=;
j=i+;
}
else if(no[i].num==&&i==j){ans[i]=;j++;}
}
for(int i=;i<n;i++)
{
if(ans[i]<)puts(s[ans[i]]);
else printf("%d %s\n",ans[i]-,s[ans[i]]);
}
return ;
}

D - Dima and Hares

dp:

这个题挺不错的;

before[i]代表第i个兔子比它前面的那个先喂;

after[i]代表第i个兔子比它前面那个后喂;

然后扫一遍就行,注意边界条件

 #include<cstdio>
#include<algorithm>
#define maxn 3005
using namespace std; int map[][maxn];
int before[maxn],after[maxn]; int main()
{
int n;
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
for(int i=;i<=n;i++)
scanf("%d",&map[][i]);
before[]=;
after[]=-;
for(int i=;i<=n+;i++)
{
before[i]=max(before[i-]+map[][i-],after[i-]+map[][i-]);
after[i]=max(before[i-]+map[][i-],after[i-]+map[][i-]);
}
printf("%d\n",after[n+]);
return ;
}

Codeforces Round #208 (Div. 2)的更多相关文章

  1. Codeforces Round #208 (Div. 2) 358D Dima and Hares

    题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...

  2. Codeforces Round #208 (Div. 2) A.Dima and Continuous Line

    #include <iostream> #include <algorithm> #include <vector> using namespace std; in ...

  3. Codeforces Round #208 (Div. 2) B Dima and Text Messages

    #include <iostream> #include <algorithm> #include <string> using namespace std; in ...

  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. 关于Eclipse的常用快捷键

    最近用到了一些以前开发中没有用到的Eclipse中的快捷键,现在总结如下: Ctrl+Shift+G 全局 工作区中的引用 使用的图解: 在所选定的类上,按下Ctrl+Shift+G在Search的T ...

  2. wsdl 关于nillable和minOccurs 在.NET和java中的不同

    术语约定文章中会反复出现[值类型].[包装类型].[普通引用类型].[元素节点]和[元素取值]的表述1> [值类型]指的是java和.NET中的基本数据类型,如:int:2> [包装类型] ...

  3. PHP输入流php://input介绍

    在使用xml-rpc的时候,server端获取client数据,主要是通过php输入流input,而不是$_POST数组.所以,这里主要探讨php输入流php://input 对一php://inpu ...

  4. 认识JSON

    JSON 全称 JavaScript Object Notation,意思是JavaScript对象表示法.是一种基于文本的.独立于语言的轻量级数据交换格式.易于阅读和编写,易于机器解析和生成. 一. ...

  5. 在XP系统下搭建maven环境出的问题 Unable to locate the Javac Compiler in: C:\Program Files\Java\jre6\..\lib\tools.jar

    Build errors for spider; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute g ...

  6. Linux中的版本控制---diff和patch命令

    一.构造两个用于测试的文件 hello.txt: world.txt: 二.用diff命令比较两个文本文件的差异 对这个两个文本文件执行diff‘命令,并通过输出重定向,将差异保存在diff.txt文 ...

  7. ###《Effective STL》--Chapter1

    点击查看Evernote原文. #@author: gr #@date: 2014-09-12 #@email: forgerui@gmail.com Chapter1 容器 Topic 4: 调用e ...

  8. html-----017

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  9. [PS] 透明底图片制作

    网页中有时需要自己绘制一些图片,或者现有的图片希望修改底色,这些都会用到透明底色的图片,下面总结两种方法,比较简单入门. 一.自己制作透明底图片 步骤1.新建图片,背景内容选择透明: 步骤2.选择文字 ...

  10. C语言经典案例

    题目:企业发放的奖金根据利润提成.利润(I)低于或等于10万元时,奖金可提10%:利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%:20万到40万 ...