QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#763634 | #6609. Scholomance Academy | mhw | WA | 342ms | 36112kb | C++23 | 1.5kb | 2024-11-19 21:20:14 | 2024-11-19 21:20:14 |
Judging History
answer
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long
#define pii pair<ll, ll>
const ll inf = 2e18;
const double eps = 1e-9;
using namespace std;
void slv(){
ll n; cin >> n;
vector<pii> a(n + 1);
for(int i = 1; i <= n; ++i) {
ll x; string s;
cin >> s >> x;
a[i] = {s[0] == '+' ? 1 : -1, x};
}
ll sump = 0, sumn = 0, tp = 0, fp = 0;
for(int i = 1; i <= n; ++i) {
if(a[i].first == 1) {
sump ++;
} else {
sumn++;
}
}
sort(a.begin() + 1, a.end(), [&](pii x, pii y) {
return x.second < y.second;
});
vector<pii> ans;
ans.push_back({0, 0});
for(int i = 1, j; i <= n; ++i) {
for(j = i; j <= n && a[j].second == a[i].second; ++j);
--j;
for(int k = i; k <= j; ++k) {
if(a[k].first == 1) tp++;
if(a[k].first == -1) fp++;
}
ans.push_back({tp, fp});
i = j;
}
// cout << "ok" << endl;
ll Ans = 0;
ll maxn = 0.0, lst = 0.0;
sort(ans.begin(), ans.end(), [&](pii x, pii y){
return x.second < y.second;
});
for(auto [p, f]: ans) {
maxn = max(maxn, p);
Ans += maxn * (f - lst);
lst = f;
}
cout << fixed << setprecision(14) << ((long double)0.0 + sump * sumn - Ans) / (sump * sumn) << endl;
}
int main(){
//ios::sync_with_stdio(0), cin.tie(0);
int _ = 1;
//cin >> _;
while(_--) slv();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4036kb
input:
3 + 2 - 3 - 1
output:
0.50000000000000
result:
ok found '0.500000000', expected '0.500000000', error '0.000000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
6 + 7 - 2 - 5 + 4 - 2 + 6
output:
0.88888888888889
result:
ok found '0.888888889', expected '0.888888889', error '0.000000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 4044kb
input:
8 + 34 + 33 + 26 - 34 - 38 + 39 - 7 - 27
output:
0.56250000000000
result:
ok found '0.562500000', expected '0.562500000', error '0.000000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
2 + 12345135 - 12345135
output:
0.00000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
2 + 4 - 3
output:
1.00000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 3816kb
input:
2 - 3 + 4
output:
1.00000000000000
result:
ok found '1.000000000', expected '1.000000000', error '0.000000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
2 - 12 + 11
output:
0.00000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
2 + 7 - 9
output:
0.00000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
2 - 4 + 4
output:
0.00000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #10:
score: 0
Accepted
time: 159ms
memory: 18792kb
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:
0.00000000000000
result:
ok found '0.000000000', expected '0.000000000', error '-0.000000000'
Test #11:
score: 0
Accepted
time: 172ms
memory: 18840kb
input:
999999 + 2 - 1 + 1 - 2 + 2 - 1 - 1 + 1 - 2 + 2 - 1 - 2 + 1 - 2 - 1 + 2 - 2 - 1 - 1 - 2 + 2 + 1 - 1 - 2 + 2 + 1 - 1 - 1 + 2 - 2 + 2 - 1 + 1 + 1 - 2 + 2 + 1 + 2 + 1 + 2 - 2 + 1 - 2 + 1 - 2 + 2 + 2 - 1 - 1 - 1 + 2 + 1 + 2 - 1 - 1 - 2 + 2 - 1 + 2 - 2 - 2 + 1 + 1 + 1 + 2 + 2 + 2 + 2 + 1 - 2 - 2 - 1 - 1 -...
output:
0.24973813735329
result:
ok found '0.249738137', expected '0.249738137', error '0.000000000'
Test #12:
score: 0
Accepted
time: 172ms
memory: 18724kb
input:
1000000 + 2 + 1 - 2 - 1 + 2 - 1 + 1 + 1 - 1 + 2 - 2 + 1 + 2 - 1 - 2 - 1 + 2 + 1 + 2 - 1 - 2 - 2 - 1 - 1 + 1 - 1 - 1 - 1 - 1 - 2 - 1 + 2 - 1 + 1 - 1 + 2 + 1 + 1 - 2 + 1 + 1 + 2 - 2 - 2 - 1 - 1 - 1 + 2 + 2 + 1 - 1 + 2 - 1 + 2 - 2 + 1 - 1 + 1 + 2 + 1 - 1 + 1 + 1 + 2 - 2 + 2 + 2 - 1 + 1 - 2 + 2 + 1 + 1 ...
output:
0.24949178189850
result:
ok found '0.249491782', expected '0.249491782', error '0.000000000'
Test #13:
score: 0
Accepted
time: 198ms
memory: 18832kb
input:
999999 + 20 - 6 + 13 - 20 - 19 + 17 + 13 - 8 + 3 + 6 - 17 + 17 + 16 - 16 + 8 + 11 - 7 - 20 - 13 + 6 - 7 + 19 + 10 - 5 - 9 - 16 - 17 + 13 + 7 + 18 - 17 + 13 + 16 + 10 + 17 - 9 - 6 + 11 - 7 + 8 - 5 + 20 - 18 + 1 + 8 - 9 + 4 + 5 + 14 - 11 - 15 - 8 - 7 - 7 + 15 + 15 + 8 - 3 + 13 - 5 + 9 - 14 + 6 - 8 + 3...
output:
0.47415371150088
result:
ok found '0.474153712', expected '0.474153712', error '0.000000000'
Test #14:
score: 0
Accepted
time: 195ms
memory: 18812kb
input:
1000000 + 22 - 6 + 13 - 20 - 19 + 24 + 24 - 15 + 17 + 3 + 23 + 20 - 17 + 23 + 16 - 21 - 22 + 8 + 11 - 23 + 17 - 24 - 13 + 6 - 7 + 19 + 21 - 14 + 18 - 22 - 11 - 21 - 21 + 13 + 24 + 20 + 18 - 17 + 13 + 16 + 10 + 25 - 24 - 14 + 7 - 15 + 22 + 8 - 5 + 20 - 18 + 1 + 8 - 9 + 4 + 25 + 1 - 9 - 9 - 14 + 14 + ...
output:
0.47954169616097
result:
ok found '0.479541696', expected '0.479541696', error '0.000000000'
Test #15:
score: 0
Accepted
time: 236ms
memory: 18788kb
input:
999999 - 595 + 975 + 320 - 300 + 871 - 170 + 103 - 360 + 868 - 631 - 851 - 509 + 725 + 627 - 983 - 63 - 845 + 367 + 1000 - 980 - 846 - 605 - 987 + 582 - 367 - 724 - 579 + 944 + 566 - 873 - 889 - 991 + 562 + 209 + 625 + 328 - 463 + 673 + 77 + 365 - 275 + 667 - 424 - 85 + 942 + 504 + 447 - 90 + 780 + ...
output:
0.50035494122561
result:
ok found '0.500354941', expected '0.500354941', error '0.000000000'
Test #16:
score: 0
Accepted
time: 240ms
memory: 18908kb
input:
1000000 - 18 - 59 - 824 + 193 - 373 - 462 - 707 + 765 - 285 - 664 + 186 - 374 - 360 + 295 - 339 + 144 - 88 + 96 - 103 + 809 - 453 - 624 - 509 - 435 + 158 + 503 + 160 + 194 - 579 + 135 - 276 + 605 - 564 - 549 - 219 - 246 - 399 - 893 + 166 + 749 - 551 + 729 + 787 - 507 + 563 + 222 + 767 - 117 - 232 - ...
output:
0.49961580680244
result:
ok found '0.499615807', expected '0.499615807', error '0.000000000'
Test #17:
score: -100
Wrong Answer
time: 342ms
memory: 36112kb
input:
999999 + 649917 - 505960 - 144512 - 570407 + 262265 - 623272 + 743202 - 886356 - 199591 + 951022 + 966769 + 770209 + 256025 - 118843 + 168738 + 516944 + 160812 - 283717 + 254929 - 442969 - 897288 + 74809 - 419482 - 845143 - 967020 + 883637 - 767990 - 173181 + 230007 + 638724 - 950239 + 836557 + 7156...
output:
0.49993230945763
result:
wrong answer 1st numbers differ - expected: '0.4999326', found: '0.4999323', error = '0.0000003'