QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#638629 | #6609. Scholomance Academy | potential | WA | 0ms | 3880kb | C++20 | 1.5kb | 2024-10-13 16:26:41 | 2024-10-13 16:26:41 |
Judging History
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();
}
}
Details
Tip: Click on the bar to expand more detailed information
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