/ 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:30:19: warning: unused variable 'p' [-Wunused-variable]
   int f[1001]={0},p;
                   ^
# 状态 耗时 内存占用
#1 Accepted 4ms 384.0 KiB
#2 Accepted 3ms 360.0 KiB
#3 Accepted 3ms 344.0 KiB
#4 Accepted 4ms 348.0 KiB
#5 Accepted 26ms 368.0 KiB
#6 Accepted 52ms 364.0 KiB
#7 Accepted 389ms 500.0 KiB
#8 Accepted 510ms 472.0 KiB
#9 Wrong Answer 506ms 356.0 KiB
#10 Accepted 722ms 360.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)
{
	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++;
	/*cout<<"[";
	for(i=head;i<=tail;i++)
		cout<<q[i].x<<" ";
	cout<<"]"<<endl;*/
	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++)
			cout<<f[i]<<" ";
		cout<<endl;*/
		for(i=1;i<=n;i++)
		{
			j=getmin(f[i-1],i-1);
			//cout<<j<<endl;
			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:27:39
评测时间
2017-10-12 20:27:39
评测机
分数
90
总耗时
2222ms
峰值内存
500.0 KiB