QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#216366#6609. Scholomance AcademyTdfcccTL 0ms4060kbC++14986b2023-10-15 17:45:352023-10-15 17:45:36

Judging History

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

  • [2023-10-15 17:45:36]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:4060kb
  • [2023-10-15 17:45:35]
  • 提交

answer

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

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<int> v(n);
	vector<char> c(n);
	for(int i = 0; i < n; i ++)
		cin >> c[i] >> v[i];
	set<double> st;
	map<double, double> to;
	for(auto x : v)
	{
		int TP = 0, FN = 0, FP = 0, TN = 0;
		for(int j = 0; j < n; j ++)
		{
			if(v[j] >= x)
			{
				if(c[j] == '+') TP ++;
				else FP ++;
			}
			else
			{
				if(c[j] == '+') FN ++;
				else TN ++;
			}
		}
		double TPR = TP * 1.0 / (TP + FN);
		double FPR = FP * 1.0 / (TN + FP);
		if(!st.count(FPR))
		{
			st.insert(FPR);
			to[FPR] = TPR;
		}
		else
		{
			to[FPR] = max(to[FPR], TPR);
		}
	}
	
	double now1 = 0;
	double now2 = 0;
	double ans = 0;
	for(auto x : st)
	{
		if(x == 0)
		{
			now2 = to[x];
			continue;
		}
		ans += (x - now1) * now2;
		now1 = x;
		now2 = to[x];
	}
	cout << fixed << setprecision(12) << ans << endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 3756kb

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

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

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

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

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

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

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

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: