QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#216948 | #6609. Scholomance Academy | Tdfccc | TL | 0ms | 4048kb | C++14 | 1.1kb | 2023-10-16 09:45:33 | 2023-10-16 09:45:34 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
struct node
{
double t,f;
};
bool cmp(node a, node b)
{
if(a.f==b.f) return a.t < b.t;
return a.f < b.f;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<int> v(n);
vector<char> c(n);
for(int i = 0; i < n; i ++)
cin >> c[i] >> v[i];
set<double> st;
map<double, double> to;
set<double> check;
vector<node> vn;
for(auto x : v)
{
int TP = 0, FN = 0, FP = 0, TN = 0;
for(int j = 0; j < n; j ++)
{
if(v[j] >= x)
{
if(c[j] == '+') TP ++;
else FP ++;
}
else
{
if(c[j] == '+') FN ++;
else TN ++;
}
}
double TPR = TP * 1.0 / (TP + FN);
double FPR = FP * 1.0 / (TN + FP);
vn.push_back({TPR,FPR});
}
sort(vn.begin(),vn.end(),cmp);
double now1 = 0;
double now2 = 0;
double ans = 0;
bool flag = true;
for(auto x : vn)
{
if(flag)
{
flag = false;
now1 = x.f;
now2 = x.t;
continue;
}
ans += (x.f - now1) * now2;
now1 = x.f;
now2 = x.t;
}
cout << fixed << setprecision(12) << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3820kb
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: 3968kb
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: 3752kb
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: 0ms
memory: 3824kb
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: 3808kb
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: 4048kb
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: 3812kb
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: 3908kb
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: 3752kb
input:
2 - 4 + 4
output:
0.000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #10:
score: -100
Time Limit Exceeded
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 ...