QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#757797#6609. Scholomance Academydad11RE 0ms3948kbC++14649b2024-11-17 13:34:342024-11-17 13:34:36

Judging History

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

  • [2024-11-17 13:34:36]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3948kb
  • [2024-11-17 13:34:34]
  • 提交

answer

#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

struct node{
	char op;
	int  s;
}a[100050];

int cmp(node a,node b){
	if(a.s == b.s){
		return a.op < b.op;
	}else
		return a.s < b.s;
}

int main(){
	
	
	int n;
	scanf("%d",&n);
	getchar();
	double s1 = 0,s2 = 0;
	
	for(int i = 1;i<=n;i++){
		scanf("%c%d",&a[i].op,&a[i].s);
		getchar();
		if(a[i].op == '+') s1++;
		else s2++;
	}
	
	sort(a+1,a+n+1,cmp);
	
	double ans = 0.0,t = 1.0;
	
	for(int i = 1;i<=n;i++){
		
		if(a[i].op == '-') ans += t * 1.0 / s2;
		else t = t - 1.0 / s1; 
	}
	printf("%.10lf",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
+ 2
- 3
- 1

output:

0.5000000000

result:

ok found '0.500000000', expected '0.500000000', error '0.000000000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

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

output:

0.8888888889

result:

ok found '0.888888889', expected '0.888888889', error '0.000000000'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

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

output:

0.5625000000

result:

ok found '0.562500000', expected '0.562500000', error '0.000000000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3832kb

input:

2
+ 12345135
- 12345135

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3912kb

input:

2
+ 4
- 3

output:

1.0000000000

result:

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

Test #6:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

2
- 3
+ 4

output:

1.0000000000

result:

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

Test #7:

score: 0
Accepted
time: 0ms
memory: 3948kb

input:

2
- 12
+ 11

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

2
+ 7
- 9

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3900kb

input:

2
- 4
+ 4

output:

0.0000000000

result:

ok found '0.000000000', expected '0.000000000', error '-0.000000000'

Test #10:

score: -100
Runtime Error

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: