PersonalCorpus 版 (精华区)
寄信人: No (hi)
标 题: 1265
发信站: 哈工大紫丁香 (2002年06月11日18:36:34 星期二)
来 源: 202.118.239.224
19164 2002-06-11 18:34:32
Accepted 1265 C++ 00:00.23 2444K Big Guava
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
#ifdef LOCAL_DEBUG
freopen("c:\\lcc\\input_zju1265.txt","r",stdin);
freopen("c:\\lcc\\output_zju1265.txt","w",stdout);
#endif
int *p,*r;
int i,len;
int forward;
int tot;
char buf[300];
p=(int *) malloc(1048576L);
r=(int *) malloc(1048576L);
while (!feof(stdin)) {
len=0;
while (gets(buf)!=NULL) {
if (strlen(buf)==0) break;
sscanf(buf,"%d%d",&p[len],&r[len]);
if (p[len]==0) r[len]=1;
len++;
}
if (len==0) break;
forward=0; tot=0;
for (i=len-1;i>0;i--) {
forward-=r[i];
if (forward<p[i]) forward=p[i];
if ((p[i]==0)&&(forward<=0)) tot++;
}
printf("%d\n",tot);
}
free(p);
free(r);
}
--
※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.224]
--
※ 转寄:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 202.118.239.224]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:5.305毫秒