/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'int getmin(int, int)':
/in/foo.cc:12:6: warning: unused variable 'i' [-Wunused-variable]
  int i;
      ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:26:19: warning: unused variable 'p' [-Wunused-variable]
   int f[1001]={0},p;
                   ^
# 状态 耗时 内存占用
#1 Accepted 3ms 360.0 KiB
#2 Accepted 3ms 384.0 KiB
#3 Accepted 3ms 384.0 KiB
#4 Accepted 6ms 360.0 KiB
#5 Accepted 41ms 364.0 KiB
#6 Accepted 52ms 376.0 KiB
#7 Accepted 355ms 352.0 KiB
#8 Accepted 543ms 508.0 KiB
#9 Wrong Answer 609ms 476.0 KiB
#10 Accepted 737ms 512.0 KiB

代码

#include <bits/stdc++.h>
using namespace std;
int n,m,t,s;
int v[1001]={0};
struct quque
{
	int x,y;
}q[1001];
int head,tail;
int getmin(int x,int y)//x:值,y:下标 
{
	int i;
	while(head<=tail&&q[tail].x>=x) 
		tail--;
	q[++tail].x=x,q[tail].y=y;
	while(y-q[head].y+1>t)
		head++;
	return q[head].y;
}
int main()
{
	int i,j;
	scanf("%d %d %d",&n,&m,&t);
	while(m--)
	{
		int f[1001]={0},p;
		int value=0,left=0,right=0;
		head=1,tail=0;
		for(i=1;i<=n;i++)
		{
			scanf("%d",&s);
			f[i]=f[i-1]+s;
		}
		for(i=1;i<=n;i++)
		{
			j=getmin(f[i-1],i-1);
			if(f[i]-f[j]>=value)
			{
				value=f[i]-f[j];
				left=j+1,right=i;
			}
		}
		for(i=left;i<=right;i++)
			v[i]++;
	}
	for(i=1;i<=n;i++)
		printf("%d ",v[i]);
	return 0;
}

信息

递交者
类型
递交
题目
骂战(原创)
题目数据
下载
语言
C++
递交时间
2017-10-12 20:36:03
评测时间
2017-10-12 20:36:03
评测机
分数
90
总耗时
2357ms
峰值内存
512.0 KiB