QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#529437 | #9229. Juliet Unifies Ones | ucup-team4717# | WA | 0ms | 3772kb | C++14 | 709b | 2024-08-24 13:10:32 | 2024-08-24 13:10:32 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
inline int read(){
int x=0,f=1;char ch=getchar_unlocked();
while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar_unlocked();}
while(isdigit(ch)){x=(x<<1)+(x<<3)+ch-48,ch=getchar_unlocked();}
return x*f;
}
int n,sum[N];
string s;
signed main(){
// freopen("love.in","r",stdin);
// freopen("love.out","w",stdout);
cin>>s;
n=s.size();
s=' '+s;
int ans=1e18;
for(int i=1;i<=n;i++) sum[i]=sum[i-1]+(s[i]=='1');
for(int i=1;i<=n;i++){
for(int j=i;j<=n;j++){
int res=j-i+1-(sum[j]-sum[i-1]);
res+=(sum[i-1]);
res+=(sum[n]-sum[j]);
ans=min(ans,res);
}
}
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3600kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3604kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3644kb
input:
00000000000000000000000000000000000000000000000000
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'