QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#791525 | #6609. Scholomance Academy | Hans | WA | 76ms | 11576kb | C++23 | 936b | 2024-11-28 19:21:38 | 2024-11-28 19:21:39 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
struct s {
bool plus;
int val;
bool const operator<(const struct s& o) {
return val > o.val;
}
};
int main() {
ios::sync_with_stdio(false);
int n; cin >> n;
int tp = 0, fp = 0, fn = 0, tn = 0;
vector<struct s> v;
char plus;
int val;
while (n--) {
cin >> plus >> val;
v.push_back({.plus = plus == '+', .val=val});
if (plus == '+') fn++;
else tn++;
}
sort(v.begin(), v.end());
double total = 0;
double tpr = 0;
double fpr = 0;
for (int i = 0; i < v.size(); i++) {
do {
if (v[i].plus) {tp++;fn--;}
else {fp++;tn--;}
} while (i < v.size()-1 && v[i].val == v[i+1].val && i++);
double newfpr = (double)fp/(fp+tn);
total += tpr * (newfpr - fpr);
tpr = (double)tp/(tp+fn);
fpr = newfpr;
}
cout << setprecision(12) << total;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3756kb
input:
3 + 2 - 3 - 1
output:
0.5
result:
ok found '0.500000000', expected '0.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3976kb
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: 3804kb
input:
8 + 34 + 33 + 26 - 34 - 38 + 39 - 7 - 27
output:
0.5625
result:
ok found '0.562500000', expected '0.562500000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3940kb
input:
2 + 12345135 - 12345135
output:
0
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
2 + 4 - 3
output:
1
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
2 - 3 + 4
output:
1
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3984kb
input:
2 - 12 + 11
output:
0
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
2 + 7 - 9
output:
0
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
2 - 4 + 4
output:
0
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #10:
score: -100
Wrong Answer
time: 76ms
memory: 11576kb
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:
2.00089640159e-06
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '0.0000020', error = '0.0000020'