QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#638633#6609. Scholomance AcademypotentialWA 0ms4048kbC++201.5kb2024-10-13 16:27:192024-10-13 16:27:21

Judging History

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

  • [2024-10-13 16:27:21]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:4048kb
  • [2024-10-13 16:27:19]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define int long long
#define ull unsigned long long
#define fi first
#define se second
#define pi pair<int,int>

const int N=1e6+10;
const int INF=1e18;

double TPR(int TP,int FN){
    if(FN+TP==0) return 0;
    return (double)TP/(FN+TP);
}

double FPR(int FP,int TN){
    if(TN+FP==0) return 0;
    return (double)FP/(TN+FP);
}

void solve(){
    int n;
    // scanf("%lld",&n);
    cin>>n;
    vector<pair<char,int>> v;
    int tp=0,fn=0,fp=0,tn=0;
    for(int i=1;i<=n;i++){
        char c;
        int s;
        // scanf("%c%lld",&c,&s);
        cin>>c>>s;
        if(c=='+') fn++;
        else tn++;
        v.push_back({c,s});
    }
    sort(v.begin(),v.end(),[](pair<char,int> a,pair<char,int> b){return a.second<b.second;});
    double ans = 0;
    double last;
    // cout<<TPR(tp,fn)<<" "<<FPR(fp,tn)<<"\n";
    last=FPR(fp,tn);
    // last=0;
    for(int i=n-1;i>=0;i--){
        if(v[i].first=='-') tn--,fp++;
        if(v[i].first=='+') fn--,tp++;
        // cerr<<i<<" "<<FPR(fp,tn)<<" "<<last<<"\n";
        ans+=(FPR(fp,tn)-last)*TPR(tp,fn);
        // cerr<<(FPR(fp,tn)-last)*TPR(tp,fn)<<"\n";
        // cout<<FPR(fp,tn)<<" "<<TPR(tp,fn)<<"\n";
        last=FPR(fp,tn);
    }
    cout<<fixed<<setprecision(10)<<ans<<"\n";
    // printf("%.9lf\n",ans);
    // cout<<ans<<"\n";
}

signed main(){
    IOS
    int _=1;
    // cin>>_;
    while(_--){
        solve();
    }
}

詳細信息

Test #1:

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

input:

3
+ 2
- 3
- 1

output:

0.5000000000

result:

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

Test #2:

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

input:

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

output:

0.8888888889

result:

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

Test #3:

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

input:

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

output:

0.5625000000

result:

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

Test #4:

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

input:

2
+ 12345135
- 12345135

output:

0.0000000000

result:

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

Test #5:

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

input:

2
+ 4
- 3

output:

1.0000000000

result:

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

Test #6:

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

input:

2
- 3
+ 4

output:

1.0000000000

result:

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

Test #7:

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

input:

2
- 12
+ 11

output:

0.0000000000

result:

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

Test #8:

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

input:

2
+ 7
- 9

output:

0.0000000000

result:

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

Test #9:

score: -100
Wrong Answer
time: 0ms
memory: 3864kb

input:

2
- 4
+ 4

output:

1.0000000000

result:

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