QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#579463 | #9229. Juliet Unifies Ones | LX1288# | WA | 0ms | 3864kb | C++14 | 652b | 2024-09-21 13:58:17 | 2024-09-21 13:58:18 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
inline int rd() {
int x=0,w=0;char ch=0;
while(ch<48||ch>57)w|=ch==45,ch=getchar();
while(ch>=48&&ch<=57)x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
return w?-x:x;
}
string s;
int main(){
ios::sync_with_stdio(false),cin.tie(0);
cin>>s;
int n=s.size();
int cnt=0;
for(int i=0;i<n;i++)if(s[i]=='1')cnt++;
int ans=1e6;
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
int cnt1=0,cnt2=0;
for(int o=i;o<=j;o++){
if(s[o]=='1')cnt1++;
else cnt2++;
}
// printf("%d %d %d\n",cnt2,cnt,cnt1);
ans=min(ans,cnt2+cnt-cnt1);
}
}
printf("%d\n",ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3788kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3864kb
input:
00000000000000000000000000000000000000000000000000
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'