QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#559023 | #8832. Daily Disinfection | AChievedreaM# | WA | 0ms | 3608kb | C++17 | 746b | 2024-09-11 19:43:52 | 2024-09-11 19:43:56 |
Judging History
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'