Codeforces Round #208 (Div. 2)
水题:直接模拟;
#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 ;
}
水题:按照顺序找就行了
#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 ;
}
水题:直接模拟,三个容器每个放一个大的,其他小的都放在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 ;
}
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)的更多相关文章
- Codeforces Round #208 (Div. 2) 358D Dima and Hares
题目链接:http://codeforces.com/problemset/problem/358/D 开始题意理解错,整个就跪了= = 题目大意:从1到n的位置取数,取数的得到值与周围的数有没有取过 ...
- Codeforces Round #208 (Div. 2) A.Dima and Continuous Line
#include <iostream> #include <algorithm> #include <vector> using namespace std; in ...
- Codeforces Round #208 (Div. 2) B Dima and Text Messages
#include <iostream> #include <algorithm> #include <string> using namespace std; in ...
- 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 ...
随机推荐
- LeetCode里有特色的问题存档
002* Median of Two Sorted Arrays There are two sorted arrays A and B of size m and n respectively. F ...
- JavaScript入门(10)
一.Window对象 window对象是BOM的核心,window对象指当前的浏览器窗口 window对象方法 二.JavaScript计时器 在JavaScript中,我们可以在设定的时间间隔之后来 ...
- JAXB - Unmarshalling
A simple approach for unmarshalling an XML document consists of the creation of a JAXB context and t ...
- APPlication,Session,Cookie,ViewState和Cache之间的区别
1.Application:用于保存所有用户共用的数据信息. 在Asp.Net中类似的配置数据最好保存在Web.config文件中.如果使用Application对象,一个需要考虑的问题是任何写操作都 ...
- Android数据存储方式之SharedPreferences
Android平台给我们提供了一个SharedPreferences类,它是一个轻量级的存储类,特别适合用于保存软件配置参数.使用SharedPreferences保存数据,其背后是用xml文件存放数 ...
- SQL Server调优系列进阶篇 - 深入剖析统计信息
前言 经过前几篇的分析,其实大体已经初窥到SQL Server统计信息的重要性了,所以本篇就要祭出这个神器了. 该篇内容会很长,坐好板凳,瓜子零食之类... 不废话,进正题 技术准备 数据库版本为SQ ...
- 【转】代码高处走 从VC6到VC9移植代码问题说明
首先可以直接用Visual Studio 2008的打开VC6的工作区文件和项目文件(dsw和dsp),并将其升级为VS2008的解决方案格式和项目格式(sln和vcproj),VC9的编译器相对于V ...
- OCI_ERROE - errcode[1591],errmsg[ORA-01591:
CEASYDAO: 错误码[1591],错误信息[Error - OCI_ERROE - errcode[1591],errmsg[ORA-01591: lock held by in-doubt d ...
- 第11条:谨慎地覆盖clone
Clone提供一种语言之外的机制:无需调用构造器就可以创建对象. 它的通用约定非常弱: 创建和返回该对象的一个拷贝.这个拷贝的精确含义取决于该对象的类.一般含义是,对于任何对象x,表达式x.clone ...
- 字符设备驱动、平台设备驱动、设备驱动模型、sysfs的比较和关联
转载自:http://www.kancloud.cn/yueqian_scut/emlinux/106829 学习Linux设备驱动开发的过程中自然会遇到字符设备驱动.平台设备驱动.设备驱动模型和sy ...