QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#638629#6609. Scholomance AcademypotentialWA 0ms3880kbC++201.5kb2024-10-13 16:26:412024-10-13 16:26:41

Judging History

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

  • [2024-10-13 16:26:41]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3880kb
  • [2024-10-13 16:26:41]
  • 提交

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: 0
Wrong Answer
time: 0ms
memory: 3880kb

input:

3
+ 2
- 3
- 1

output:

0.5 0
0.5 1
1 1
0.5000000000

result:

wrong output format Extra information in the output file