QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#529437#9229. Juliet Unifies Onesucup-team4717#WA 0ms3772kbC++14709b2024-08-24 13:10:322024-08-24 13:10:32

Judging History

你现在查看的是最新测评结果

  • [2024-08-24 13:10:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3772kb
  • [2024-08-24 13:10:32]
  • 提交

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;
}

详细

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'