QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216735#6609. Scholomance Academywiseman123WA 200ms12992kbC++141.5kb2023-10-15 21:50:482023-10-15 21:50:49

Judging History

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

  • [2023-10-15 21:50:49]
  • 评测
  • 测评结果:WA
  • 用时:200ms
  • 内存:12992kb
  • [2023-10-15 21:50:48]
  • 提交

answer

// #include<bits/stdc++.h>
// using namespace std;
// const int N=1e6+10;
// struct V{ 
// 	char op; int v; 
// }a[N];
// int n,tn,fn,tp,fp;
// double ans,preX;

// bool cmp(V &a,V &b){
// 	if(a.v==b.v) return a.op<b.op;
// 	return a.v<b.v;
// }

// int main(){
// 	cin>>n;
// 	for(int i=1;i<=n;i++){
// 		cin>>a[i].op>>a[i].v;
// 		if(a[i].op=='+') fn++;
// 		else tn++;
// 	}
// 	sort(a+1,a+n+1,cmp);
// 	for(int i=n;i>=1;i--)
// 	{
// 		cout<<a[i].op<<" "<<a[i].v<<endl;
// 		if(a[i].op=='+') tp++,fn--;
// 		else fp++,tn--;
// 		ans+=1.0*tp/(tp+fn)*(1.0*fp/(tn+fp)-preX);
// 		preX=1.0*fp/(tn+fp);
// 	}
// 	cout<<setprecision(10)<<fixed<<ans<<"\n";
// }
#include <bits/stdc++.h>

const int maxn=1e6+10;
using namespace std;


priority_queue<double> a,b;
int cnt1,cnt2;
int main()
{
    int n;
    double tmp,maxn=0;
    cin>>n;
    char t;
    for(int i=1;i<=n;i++)
    {
        cin>>t>>tmp;
        if(t=='+')  {a.push(tmp),cnt1++;}
        else {b.push(tmp),cnt2++;}
        maxn=max(maxn,tmp);
    }
    double x=0,y=0,ans=0;
    
    for(int i=(int)maxn;i>=0;i--)
    {
        if(b.size()&&b.top()>=i)
        {
            b.pop();
            double tmp=x;
            x=1.0*(1.0*cnt2-1.0*b.size())/cnt2;
            ans+=y*(x-tmp);
        } 
        if(a.size()&&a.top()>=i)
        {
            a.pop();
            y=1.0*(1.0*cnt1-1.0*a.size())/cnt1;
        } 
    }
    printf("%.12lf",ans);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3828kb

input:

3
+ 2
- 3
- 1

output:

0.500000000000

result:

ok found '0.500000000', expected '0.500000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 4008kb

input:

6
+ 7
- 2
- 5
+ 4
- 2
+ 6

output:

0.888888888889

result:

ok found '0.888888889', expected '0.888888889', error '0.000000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

8
+ 34
+ 33
+ 26
- 34
- 38
+ 39
- 7
- 27

output:

0.562500000000

result:

ok found '0.562500000', expected '0.562500000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 6ms
memory: 3952kb

input:

2
+ 12345135
- 12345135

output:

0.000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

2
+ 4
- 3

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #6:

score: 0
Accepted
time: 0ms
memory: 4012kb

input:

2
- 3
+ 4

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

2
- 12
+ 11

output:

0.000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3752kb

input:

2
+ 7
- 9

output:

0.000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2
- 4
+ 4

output:

0.000000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #10:

score: 0
Accepted
time: 200ms
memory: 12992kb

input:

1000000
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
- 1
+ 1
+ 1
- 1
+ 1
- 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
+ 1
+ 1
- 1
- 1
- 1
+ 1
- 1
+ 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
- 1
+ 1
+ 1
- 1
+ 1
+ 1
- 1
+ 1
- 1
+ 1
+ 1
+ 1
+ 1
+ 1
- 1
- 1
+ 1
...

output:

0.000000000004

result:

ok found '0.000000000', expected '0.000000000', error '0.000000000'

Test #11:

score: -100
Wrong Answer
time: 198ms
memory: 11152kb

input:

999999
+ 2
- 1
+ 1
- 2
+ 2
- 1
- 1
+ 1
- 2
+ 2
- 1
- 2
+ 1
- 2
- 1
+ 2
- 2
- 1
- 1
- 2
+ 2
+ 1
- 1
- 2
+ 2
+ 1
- 1
- 1
+ 2
- 2
+ 2
- 1
+ 1
+ 1
- 2
+ 2
+ 1
+ 2
+ 1
+ 2
- 2
+ 1
- 2
+ 1
- 2
+ 2
+ 2
- 1
- 1
- 1
+ 2
+ 1
+ 2
- 1
- 1
- 2
+ 2
- 1
+ 2
- 2
- 2
+ 1
+ 1
+ 1
+ 2
+ 2
+ 2
+ 2
+ 1
- 2
- 2
- 1
- 1
-...

output:

0.000000000012

result:

wrong answer 1st numbers differ - expected: '0.2497381', found: '0.0000000', error = '0.2497381'