QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#752953#5983. Pretty Good Proportionqyzy0 564ms28532kbC++141.2kb2024-11-16 10:35:332024-11-16 10:35:33

Judging History

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

  • [2024-11-16 10:35:33]
  • 评测
  • 测评结果:0
  • 用时:564ms
  • 内存:28532kb
  • [2024-11-16 10:35:33]
  • 提交

answer

/*Life is too long to end at a grave*/
#include<bits/stdc++.h>
#define N 1000010
#define I_love_Furina return
#define forever 0
#define foreverr 1
#define endl '\n'
#define FIO(s) do{freopen(s".in","r",stdin);freopen(s".out","w",stdout);}while(false)
#define IOS ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define db long double
#define ull unsigned long long
#define chc cout<<114514<<endl
#define PDI pair<db,int>
#define fi first
#define se second
#define mk make_pair
#define eps 1e-12
#define int long long
using namespace std;
int n,T,m;
db f,sum[N];
PDI a[N];
string s;
signed main(){
    IOS;//FIO("");
	cin>>T;
	while(T--){
		m++;
		cin>>n>>f>>s;
		int ans=1e12;
		db minn=1e12;
		n=s.length();
		for(int i=1;i<=n;i++){
			sum[i]=sum[i-1]+(s[i-1]-'0')-f;
			a[i].fi=sum[i];
			a[i].se=i;
			// cout<<sum[i]<<" ";
		}
		// cout<<endl;
		sort(a,a+n+1);
		for(int i=1;i<=n;i++){
			int x=a[i].se,y=a[i-1].se;
			if(fabsl(1.0*(sum[y]-sum[x])/(y-x))<minn)minn=fabsl(1.0*(sum[y]-sum[x])/(y-x));
		}
		for(int i=1;i<=n;i++){
			int x=a[i].se,y=a[i-1].se;
			if(fabsl(fabsl(1.0*(sum[y]-sum[x])/(y-x))-minn)<eps)ans=min(ans,min(x,y)+1);
		}
		cout<<"Case #"<<m<<": ";
		cout<<ans-1<<endl;
	}
    I_love_Furina forever;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 5860kb

input:

100
10 0.827672
0010101011
4 0.932623
0100
1000 0.834002
011001110010111110000110101100010010100101101110110111100010101101111100110001011000110100010100011011000001100001010110111101111010110110000110011000111000011110101100100111111001111011011100111001011101010100111011100011110011100011110010001...

output:

Case #1: 6
Case #2: 1
Case #3: 10
Case #4: 2
Case #5: 2
Case #6: 1
Case #7: 1
Case #8: 4
Case #9: 1
Case #10: 1
Case #11: 2
Case #12: 4
Case #13: 5
Case #14: 564
Case #15: 3
Case #16: 1
Case #17: 2
Case #18: 2
Case #19: 2
Case #20: 2
Case #21: 1
Case #22: 1
Case #23: 1
Case #24: 844
Case #25: 1
Case...

result:

wrong answer 4th lines differ - expected: 'Case #4: 0', found: 'Case #4: 2'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 564ms
memory: 28532kb

input:

100
15 0.333333
000000000011000
10 0.418754
0101100001
2 0.499999
01
3 0.977951
001
2 0.249999
01
10 0.670229
0111011001
1000 0.500001
001101111110110010110000010010110001110010001101110111010011000010100011011101010110011011011010111110011100011000001000101011100011010100101101111110100101011010111...

output:

Case #1: 6
Case #2: 1
Case #3: 1
Case #4: 2
Case #5: 1
Case #6: 1
Case #7: 1
Case #8: 3
Case #9: 2
Case #10: 1
Case #11: 1
Case #12: 1
Case #13: 1
Case #14: 1
Case #15: 1
Case #16: 4333
Case #17: 1
Case #18: 1
Case #19: 553
Case #20: 1
Case #21: 1
Case #22: 1
Case #23: 2
Case #24: 2
Case #25: 1
Case...

result:

wrong answer 2nd lines differ - expected: 'Case #2: 0', found: 'Case #2: 1'