QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#655942 | #6609. Scholomance Academy | crush_codemaker# | WA | 1ms | 3988kb | C++14 | 1.1kb | 2024-10-19 10:28:31 | 2024-10-19 10:28:32 |
Judging History
answer
#include <bits/stdc++.h>
struct Value {
char sig;
int val;
};
void solve() {
int n;
std::cin >> n;
std::vector<Value> a(n + 1, {'*', 0});
for (int i = 1; i <= n; i++) {
std::cin >> a[i].sig >> a[i].val;
}
std::sort(a.begin() + 1, a.end(), [&](Value x, Value y) {
return x.val < y.val;
});
int tp = 0, fp = 0, tn = 0, fn = 0;
for (int i = 1; i <= n; i++) {
if (a[i].sig == '+') tp++;
else if (a[i].sig == '-') tn++;
}
double last = 1;
double ans = 0;
for (int i = n; i >= 1; i--) {
double rate = 1.0 * tp / (tp + fn);
if (a[i].sig == '+') tp--, fn++;
else if (a[i].sig == '-') tn--, fp++;
double cur = 1.0 * fp / (tn + fp);
ans += rate * (last - cur);
last = cur;
}
std::cout << std::fixed << std::setprecision(12) << ans << '\n';
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr), std::cout.tie(nullptr);
int T = 1;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3768kb
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: 3980kb
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: 3988kb
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: 3792kb
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: 3852kb
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: 3896kb
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: 3780kb
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: 3784kb
input:
2 + 7 - 9
output:
0.000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #9:
score: -100
Wrong Answer
time: 0ms
memory: 3832kb
input:
2 - 4 + 4
output:
1.000000000000
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '1.0000000', error = '1.0000000'