QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#559023#8832. Daily DisinfectionAChievedreaM#WA 0ms3608kbC++17746b2024-09-11 19:43:522024-09-11 19:43:56

Judging History

你现在查看的是最新测评结果

  • [2024-09-11 19:43:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-09-11 19:43:52]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using db=double;
const ll N=1e6+5;
typedef pair<ll,ll>PLL;
#define fi first
#define se second
ll a[N];
int main()
{
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll t,n;
	t=1;
	cin>>t;
	while(t--)
	{
		cin>>n;
		string s,ss="";
		cin>>s;
		ll c=0,cnt=0;
		for(ll i=0;i<n;i++)
		{
			if(s[i]=='1')
			{
				c++;
			}
			else 
			{
				ss+='1';
				ss+='0';
				if(c)
				a[++cnt]=c;
				c=0;
			}
		}
		if(c)
		{
			ss+='1';
			a[++cnt]=c;
		}
		ll minn=1e9;
		ll m=ss.size(),ans=0;
		for(ll i=1;i<=cnt;i++)
		{
			minn=min(minn,a[i]);
			ans+=a[i];
		}
		
		if(ss[0]=='1'&&ss[m-1]=='1')
			ans+=minn;
		cout<<ans<<'\n';
	}
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3608kb

input:

3
2
01
5
00110
9
101010101

output:

2
2
6

result:

wrong answer 1st numbers differ - expected: '1', found: '2'