QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589199#6609. Scholomance Academytkt0506TL 0ms4052kbC++141.1kb2024-09-25 16:38:412024-09-25 16:38:41

Judging History

你现在查看的是最新测评结果

  • [2024-09-25 16:38:41]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:4052kb
  • [2024-09-25 16:38:41]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

typedef pair<char, int> pci;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    
    vector<pci>a(n);
    int cntT = 0, cntF = 0;
    for(int i=0; i<n; i++){
        char c;
        int v;
        cin >> c >> v;
        a[i] = {c,v};
        if(c=='+')cntT++;
        else cntF++;
    }

    sort(a.begin(), a.end(), [](pci x, pci y){
        if(x.second == y.second){
            if(x.first == '+')return true;
            else return false;
        }
        else return (x.second < y.second);
    });

    int TP = cntT, FP = cntF, TN = 0, FN = 0;
    double ans = 0, last = 1;

    for(auto [c, v] : a){
        if(c=='+'){
            TP--;
            FN++;
        }else{
            FP--;
            TN++;
        }
        double TPR = (double)TP / (TP+FN);
        double FPR = (double)FP / (TN+FP);
        if(last != FPR){
            ans += TPR * (last-FPR);
            last = FPR;
        }
    }
    cout << fixed << setprecision(12) << ans;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3760kb

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: 3760kb

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: 3820kb

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: 3772kb

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: 3876kb

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: 3824kb

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: 3820kb

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: 3816kb

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: 4052kb

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
...

output:


result: