QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643174#6609. Scholomance AcademyChensenCHXWA 2ms10064kbC++232.6kb2024-10-15 19:30:412024-10-15 19:30:41

Judging History

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

  • [2024-10-15 19:30:41]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10064kb
  • [2024-10-15 19:30:41]
  • 提交

answer

//#pragma GCC optimize(2)
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define Mid (l+r)/2
#define Ls i<<1
#define Rs i<<1|1
#define Lson Ls,l,Mid
#define Rson Rs,Mid+1,r
#define For(i,a,b) for(int i=a;i<=b;i++)
#define FOr(i,a,b) for(int i=a;i>=b;i--)

using namespace std;
//using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//tree<ll,null_type,std::less<ll>,splay_tree_tag,tree_order_statistics_node_update>sp;//红黑树是rb_tree_tag

/*
inline int read()
{
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -f; c = getchar(); }
    while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
    return x * f;
}
*/
//parameter begin
#define maxN 1000010
#define M 1000000009
ll n,b[maxN],len,tp,tn,fp,fn,realp,realn,cnt;
long double tpr[maxN],fpr[maxN];
typedef struct
{
    ll s;
    char c;
}SC;
SC a[maxN];
//parameter end

//function begin
bool cmp(SC& x,SC& y)
{
    return x.s<y.s;
}
ll findx(ll x)
{
    return lower_bound(b+1,b+len+1,x)-b;
}
//function end

int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //main begin
    cin>>n;
    fp=tp=fn=tn=0;
    cnt=0;
    For(i,1,n)
    {
        cin>>a[i].c>>a[i].s;
        b[i]=a[i].s;
        if(a[i].c=='+') tp++;
        else fp++;
    }
    if(tp == n || tp == n){
        printf("0");
        return 0;
    }
    sort(b+1,b+n+1);
    len=unique(b+1,b+n+1)-b-1;
    sort(a+1,a+n+1,cmp);
    tpr[0]=(long double)tp/((long double)tp+(long double)fn),fpr[0]=(long double)fp/((long double)tn+(long double)fp);
    For(i,1,n)
    {
        if(a[i].c=='-') 
        {
            fp--;
            tn++;
        }
        if(a[i-1].c=='+')
        {
            tp--;
            fn++;
        }
        if(a[i+1].s==a[i].s) continue;
        ++cnt;
        tpr[cnt]=(long double)tp/((long double)tp+(long double)fn),fpr[cnt]=(long double)fp/((long double)tn+(long double)fp);
    }
    ++cnt;
    tpr[cnt]=fpr[cnt]=(long double)1;
    fpr[0]=tpr[0]=(long double)1;
    long double sum = 0;
    for(int i=cnt-1; i>0; i--){
        sum = sum + (fpr[i-1]-fpr[i])*tpr[i];
        //cout<<fpr[i]<<' '<<tpr[i]<<' '<<sum<<endl;

    }
    cout << fixed << setprecision(12) << sum <<"\n";
    //main end
    return 0;
}
/*
3
+ 2
- 3
- 1

6
+ 7
- 2
- 5
+ 4
- 2
+ 6

8
+ 34
+ 33
+ 26
- 34
- 38
+ 39
- 7
- 27
*/

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 10060kb

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

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: 2ms
memory: 9928kb

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: 2ms
memory: 10064kb

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

input:

2
+ 4
- 3

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #6:

score: 0
Accepted
time: 2ms
memory: 10016kb

input:

2
- 3
+ 4

output:

1.000000000000

result:

ok found '1.000000000', expected '1.000000000', error '0.000000000'

Test #7:

score: 0
Accepted
time: 2ms
memory: 9924kb

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

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: 2ms
memory: 9988kb

input:

2
- 4
+ 4

output:

1.000000000000

result:

wrong answer 1st numbers differ - expected: '0.0000000', found: '1.0000000', error = '1.0000000'