QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#521704 | #5983. Pretty Good Proportion | masterhuang | 0 | 435ms | 17588kb | C++17 | 718b | 2024-08-16 14:03:56 | 2024-08-16 14:03:58 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define LD long double
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=2e6+5;
int T,n,m,p[N];LD k,a[N];char C[N];
int main()
{
scanf("%d",&T);
for(int tt=1;tt<=T;tt++)
{
scanf("%d%Lf%s",&n,&k,C);int w=1e9;p[0]=0;
for(int i=1;i<=n;i++) a[i]=a[i-1]+C[i-1]-'0'-k,p[i]=i;
sort(p,p+1+n,[](int x,int y){return a[x]<a[y];});LD ans=1e9;
for(int i=1;i<=n;i++) ans=min(ans,abs((LD)(a[p[i]]-a[p[i-1]])/(p[i]-p[i-1])));
for(int i=1;i<=n;i++) if(abs((LD)(a[p[i]]-a[p[i-1]])/(p[i]-p[i-1]))==ans)
w=min({w,min(p[i],p[i-1])+1,max(p[i],p[i-1])});
printf("Case #%d: %d\n",tt,w-1);
}
return 0;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5992kb
input:
100 10 0.827672 0010101011 4 0.932623 0100 1000 0.834002 011001110010111110000110101100010010100101101110110111100010101101111100110001011000110100010100011011000001100001010110111101111010110110000110011000111000011110101100100111111001111011011100111001011101010100111011100011110011100011110010001...
output:
Case #1: 6 Case #2: 1 Case #3: 447 Case #4: 0 Case #5: 1 Case #6: 1 Case #7: 0 Case #8: 0 Case #9: 0 Case #10: 0 Case #11: 0 Case #12: 4 Case #13: 5 Case #14: 564 Case #15: 0 Case #16: 0 Case #17: 0 Case #18: 0 Case #19: 0 Case #20: 0 Case #21: 979 Case #22: 1 Case #23: 0 Case #24: 844 Case #25: 0 C...
result:
wrong answer 3rd lines differ - expected: 'Case #3: 10', found: 'Case #3: 447'
Subtask #2:
score: 0
Wrong Answer
Test #2:
score: 0
Wrong Answer
time: 435ms
memory: 17588kb
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: 0 Case #4: 2 Case #5: 0 Case #6: 1 Case #7: 0 Case #8: 0 Case #9: 2 Case #10: 1 Case #11: 0 Case #12: 0 Case #13: 0 Case #14: 0 Case #15: 0 Case #16: 4333 Case #17: 0 Case #18: 0 Case #19: 462 Case #20: 1 Case #21: 1 Case #22: 1 Case #23: 1 Case #24: 40 Case #25: 0 Cas...
result:
wrong answer 2nd lines differ - expected: 'Case #2: 0', found: 'Case #2: 1'