QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643198#6609. Scholomance AcademyChensenCHXWA 2ms10008kbC++232.6kb2024-10-15 19:45:422024-10-15 19:45:43

Judging History

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

  • [2024-10-15 19:45:43]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:10008kb
  • [2024-10-15 19:45:42]
  • 提交

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; 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
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 10008kb

input:

3
+ 2
- 3
- 1

output:

-0.500000000000

result:

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