/ tabris /

记录详情

Wrong Answer

/in/foo.cc: In function 'int main()':
/in/foo.cc:21:36: warning: format '%lld' expects argument of type 'long long int', but argument 3 has type 'int' [-Wformat=]
    printf("Case #%d: %lld\n",ca++,0);
                                    ^
# 状态 耗时 内存占用
#1 Wrong Answer 3ms 376.0 KiB
#2 Wrong Answer 3ms 456.0 KiB
#3 Wrong Answer 4ms 328.0 KiB
#4 Wrong Answer 3ms 344.0 KiB
#5 Wrong Answer 4ms 328.0 KiB
#6 Wrong Answer 64ms 1.32 MiB
#7 Wrong Answer 70ms 1.27 MiB
#8 Wrong Answer 76ms 1.328 MiB
#9 Wrong Answer 66ms 1.367 MiB

代码

#include<bits/stdc++.h>

using namespace std;

const int maxn = 1e6+5;
char s[maxn];
typedef long long ll;
int k;

int main()
{
	int _;
	cin>>_;
	int ca = 1;
	while(_--)
	{
		scanf("%d",&k);
		scanf("%s",s);
		if(k==0)
		{
			printf("Case #%d: %lld\n",ca++,0);
			continue;
		}
		int len = strlen(s);
		ll sum = 0;
		ll ans = 0;
		int l = 0,r = 0;
		while(r < len && r-l+1 <=k)
			{
				int cha = r-l;
				ans += (s[r]-'0')*(1<<cha);
				r++;
			}
		sum = ans;
		while(r < len)
		{
			
			while(r - l + 1 <= k)
			{
				sum += (s[r]-'0');
				r++;
			}
			ans = max(sum,ans);
			if(r>=len)
			break;
			sum -= (s[l] - '0')*(1<<(k-1));
			sum *= 2;
			l++;
		}
		printf("Case #%d: %lld\n",ca++,ans);
	} 
	return 0;
}

信息

递交者
类型
递交
题目
幸运大奖
语言
C++
递交时间
2017-09-10 21:59:32
评测时间
2017-09-10 21:59:32
评测机
分数
0
总耗时
297ms
峰值内存
1.367 MiB