C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescription:植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用"|"表示,中间的空隙用空格" "表示,首和尾肯定是

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/30 02:21:22
C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescription:植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用

C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescription:植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用"|"表示,中间的空隙用空格" "表示,首和尾肯定是
C++ACM竞赛题
植树节
Time Limit:1000MS Memory Limit:32768K
Description:
植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用"|"表示,中间的空隙用空格" "表示,首和尾肯定是一棵树.一个空格代表一个单位的空格.现在让你拔掉一定数量的树,使新的队列中最大的那个空隙最大.(忽略树本身的空隙,如果两棵树是紧挨着的,那么拔掉之后的空隙也是0)如
| || | |这么个排列,如果让你拔掉两棵树,那么最大空隙是2,即
| | |或者| | |
Input:
本题有多组数据,输入到EOF结束.每组数据第一行一个正整数N(1

C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescription:植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用"|"表示,中间的空隙用空格" "表示,首和尾肯定是
#include
#include
#include
#include
using namespace std;
const int MAX=10005;
int sum[MAX];
int bin(int low,int high,int lim,int right)
{
int ret=MAX,mid,t;
while(low>1;
t=sum[right]-sum[mid-1];
if(t>=lim)
{
ret=mid;
low=mid+1;
}
else high=mid-1;
}
return ret;
}
int main()
{
char s[MAX];
int max=0,n,t,i;
while(scanf("%d",&n)!=EOF)
{
getchar();
gets(&s[1]);
sum[0]=0;
for(i=1;s[i];i++)
{
sum[i]=sum[i-1];
if(s[i]=='|')sum[i]++;
}
max=0;
for(i=1;s[i];i++)
{
t=bin(1,i-1,n+1,i);
if(t==MAX)continue;
if((i-t+1)-(sum[i]-sum[t-1])>max)
max=(i-t+1)-(sum[i]-sum[t-1]);
}
printf("%d\n",max);
}
return 0;
}

C++ACM竞赛题植树节 Time Limit:1000MS Memory Limit:32768KDescription:植树节到了,XadillaX为了重新植一些树,不得不先拔掉一些树.这些树是整齐地排成一排,用|表示,中间的空隙用空格 表示,首和尾肯定是 c语言acm题 C语言:ACM大数运算问题.--------------------------------------------------------------------------------Time limit:1000MS Memory limit:32768K Total Submit:204 Accepted:71 ------------------------------------------------------------------------- 竞赛题, acm的一道c语言问题 acm 竞赛题xiaoA is a beautiful girl,and she has so many skirts that she won't wear a skirt a second time before the skirt is washed.Now xiaoA wants to go shopping,how many skirts she can choose to wear.In order to distinguish these skirts,she give 17.Usually Xiao Li spends __ time doing homework than XiaoChen does.A.little B less C.few D.fewe Dr.Li was so _____surfing the Internet that he forgot the time.A.carefully B.careful C.busily D.busy 一个长方形的周长是10cm,一个边长是aCM,那么这个长方形的面积是a.(10-a)aCM^2 b.(5-a)aCM^2 c.(10-2a)aCM^2 d.10aCM^2a.(10-a)aCM^2b.(5-a)aCM^2c.(10-2a)aCM^2d.10aCM^2..最好能解释清楚为什么 数学、C语言问题(ACM竞赛题)火车上列车员卖鸡腿,一共来两次,第一次A元可以买到B个鸡腿,第二次C元可以买到D个,你有M元,最多能买几个鸡腿?比如,你有5元,列车员第一次来卖3元3个,第二次来4 Miss Li requested that her students on time to every class.A.has to be B.were C.must be D.be为什么 不可以选择C ____famous magazine Asia Time recently put Li Yuchun on its cover and said that what Li possesses is attitude,originality and ____ proud androgyny.A The;aB A;the C The;the D A;× 英语翻译[6] L.Kovar,M.Gleicher,F.Pighin,“Motion Graphs,” In:Proc.of ACM SIGGRAPH,2002.[7] C.H.Liang,P.C.Tao,T.Y.Li,“IMHAP – An Experimental Platform for Humanoid Procedural Animation,” Proc.of the third International Conference on Intel Li Lei always the winner of the race ,but this time he _____othersA.fell behind B.fell down C.fell over D.fell off每个选项的中文 mary,do you know what was__?A happened to him B he doing at that time C Mr.Li's father D his favorite sport Nobody except Li Ping and Liu Ying____at school this time yesterday.A.are B.has been C.was D.Were这题选什么 Alice,do you know what was____?A.happened to him B.he doing at that time C.Mr Li's father D.his favorite subject It is______ room.A.Li Lei and Li Ming B.Li Lei‘s and Li Ming C.Li Lei’s and Li Ming‘sA.Li Lei and Li Ming B.Li Lei‘s and Li Ming C.Li Lei’s and Li Ming’s D.Li Lei and Li Ming’s