QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#554638 | #9229. Juliet Unifies Ones | _LSA_ | WA | 0ms | 3844kb | C++14 | 790b | 2024-09-09 13:38:04 | 2024-09-09 13:38:05 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define fi first
#define se second
#define mk make_pair
using namespace std;
ll read(){
ll X = 0 ,r = 1;
char ch = getchar();
while(!isdigit(ch) && ch != '-') ch = getchar();
if(ch == '-') r = -1,ch = getchar();
while(isdigit(ch)) X = X*10+ch-'0',ch = getchar();
return X*r;
}
const int N = 1111111;
int n,sum[N];
char ch[N];
int main(){
scanf("%s",ch+1);
n = strlen(ch+1);
for(int i=1;i<=n;i++)
sum[i] = sum[i-1]+(ch[i] == '1');
int ans = n;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
ans = min(ans,sum[i-1]+sum[n]-sum[j]+(j-i+1-(sum[j]-sum[i-1])));
cout << ans;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3708kb
input:
00011011001
output:
2
result:
ok 1 number(s): "2"
Test #2:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
11101111111111111101001011110111111110011101010110
output:
11
result:
ok 1 number(s): "11"
Test #3:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
00000000100000000000100000010001000
output:
3
result:
ok 1 number(s): "3"
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3776kb
input:
00000000000000000000000000000000000000000000000000
output:
1
result:
wrong answer 1st numbers differ - expected: '0', found: '1'