QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#548662 | #9229. Juliet Unifies Ones | IceCang_# | WA | 0ms | 3852kb | C++23 | 713b | 2024-09-05 19:53:37 | 2024-09-05 19:53:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int pre[60], a[60];
int tot;
int prefix0, suffix0;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int ans = INT_MAX;
string str;
cin>>str;
int l = str.length();
for(int i=0;i<l;i++) {
if(str[i]=='0') prefix0++;
if(str[i]=='1') break;
}
for(int i=l-1;i>0;i--) {
if(str[i]=='0') suffix0++;
if(str[i]=='1') break;
}
for(int i=prefix0;i<l-suffix0;i++) {
a[++tot] = str[i]-'0';
pre[tot] = pre[tot-1] + a[tot];
}
for(int i=1;i<=tot;i++) {
ans = min(ans, i-1-pre[i-1]+pre[tot]-pre[i-1]);
}
for(int i=1;i<=tot;i++) {
ans = min(ans, pre[i-1]+(tot-i+1-pre[tot]+pre[i-1]));
}
cout<<ans;
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3564kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3784kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3852kb
input:
00000000000000000000000000000000000000000000000000
output:
2147483647
result:
wrong answer 1st numbers differ - expected: '0', found: '2147483647'