/ Randle /

记录详情

Time Exceeded

/in/foo.cc:32:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
/in/foo.cc: In function 'int main()':
/in/foo.cc:39:9: warning: unused variable 'Max' [-Wunused-variable]
     int Max=INT_MAX;
         ^~~
# 状态 耗时 内存占用
#1 Accepted 3ms 364.0 KiB
#2 Accepted 3ms 356.0 KiB
#3 Accepted 3ms 364.0 KiB
#4 Accepted 7ms 368.0 KiB
#5 Accepted 58ms 376.0 KiB
#6 Accepted 102ms 344.0 KiB
#7 Time Exceeded ≥1007ms ≥352.0 KiB
#8 Time Exceeded ≥1007ms ≥344.0 KiB
#9 Time Exceeded ≥1007ms ≥368.0 KiB
#10 Time Exceeded ≥1007ms ≥352.0 KiB

代码

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<algorithm>
using namespace std;
const int maxn=1001;

int n,m,t;
int a[maxn],ans[maxn];
long long sum[maxn];

int read()
{
	int k=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return f*k;
}

main()
{
	memset(ans,0,sizeof(ans));
	memset(sum,0,sizeof(sum)); 
    n=read();
    m=read();
    t=read();
    int Max=INT_MAX;
    for(int i=1;i<=m;i++)
    {
    	int l=0,r=0;
	    for(int j=1;j<=n;j++)
	    {
		    a[j]=read();
            sum[j]=sum[j-1]+a[j];
        }
        for(int k=0;k<=n;k++)
        for(int p=k;p<=min(k+t,n);p++)
        if((sum[p]-sum[k]>sum[r]-sum[l])||(sum[p]-sum[k]==sum[r]-sum[l]&&p-k>r-l))
        {
        	r=p;
        	l=k;
		}
		for(int k=l+1;k<=r;k++)
		ans[k]++;
    }
	for(int i=1;i<=n;i++)
    cout<<ans[i]<<' ';
    cout<<endl;
    return 0;
}

信息

递交者
类型
递交
题目
骂战(原创)
题目数据
下载
语言
C++
递交时间
2017-10-12 14:04:01
评测时间
2017-10-12 17:07:48
评测机
分数
60
总耗时
≥4209ms
峰值内存
≥376.0 KiB