/ Randle /

记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:85:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(register int j=0;j<v.size();j++)
                          ~^~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 2ms 312.0 KiB
#2 Accepted 2ms 324.0 KiB
#3 Accepted 3ms 312.0 KiB
#4 Wrong Answer 2ms 436.0 KiB
#5 Wrong Answer 2ms 436.0 KiB
#6 Wrong Answer 3ms 312.0 KiB
#7 Wrong Answer 219ms 440.0 KiB
#8 Wrong Answer 240ms 324.0 KiB
#9 Wrong Answer 457ms 440.0 KiB
#10 Wrong Answer 510ms 436.0 KiB

代码

#include<iostream>
#include<cstring>
#include<queue>
#include<cstdio>
#include<vector>
using namespace std;
#define maxn 1010
#define maxm 10010
int a[maxm];
int ans[maxn];
int read()
{
	int x=0;
	int f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
		{
			f=-1;
		}
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=x*10+ch-'0';
		ch=getchar();
	}
	return x*f;
}
int n,m,t;


int main()
{
	cin>>n>>m>>t;
	memset(a,0,sizeof(a));
	for(register int i=1;i<=m;i++)//t 控制有限区间长度 
	{
		for(register int j=1;j<=n;j++)
		{
			a[j]=read();
		}
		int q[100010];
		int qh=1;
	    int qe=1;
		
		vector<int>v;
		v.clear();
		int sum=0;
		int maxf=0;//感觉想多了 没有必要控制线性的信息 主需要维护任务队列就行了  怎样优化多个并行任务? 	v 
		for(register int j=1;j<=n;j++)
	   {
		  while(qh<=qe&&q[qh]<(j-t+1))
		  {
		      sum-=a[q[qh]];
		      qh++;
		  }
		  sum=max(sum,0);
		  if(a[j]>0)
		  {
		  	sum+=a[j];
		  	q[++qe]=j;
		  	if(sum>maxf)
		  	{
		  		maxf=sum;
		  		v.clear();
		  		for(register int l=qh;l<=qe;l++)
		  		{
		  			v.push_back(q[l]); 
				  }
			  }
		  	
		  }
		  else
		  {
		  	++qe;
		  	qh=qe;
		  	sum=0;
		  }
		  
		
	   }
	   
	   for(register int j=0;j<v.size();j++)
	   {
	   	 ans[v[j]]++;
	   }
	}
	for(register int i=1;i<=n;i++)
	{
		printf("%d ",ans[i]);
	}
	return 0;
}

信息

递交者
类型
递交
题目
骂战(原创)
题目数据
下载
语言
C++
递交时间
2017-10-12 08:59:04
评测时间
2017-10-12 08:59:04
评测机
分数
30
总耗时
1445ms
峰值内存
440.0 KiB