QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#756387#8037. Gambler's Ruinryh7WA 1ms6080kbC++171.7kb2024-11-16 20:16:172024-11-16 20:16:18

Judging History

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

  • [2024-11-16 20:16:18]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:6080kb
  • [2024-11-16 20:16:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using VI = vector<int>;
using PII = pair<int,int>;
using VVI = vector<vector<int>>;
const ll mod = 998244353;
const ll INF = 1e18;
const int N = 2e6 + 10;
const double eps = 1e-9;
void solve(){
	
}
ll s[N];
int n;
pair<double , double> a[N];

double calc(int x , int y){
	double res = 0;
	double px = (double)1 / a[x].first;
	double py = (double)1 / (1.0 - a[y].first);
	double sx = s[x];
	double sy = s[n] - s[y - 1];
	//cout<<px<<py<<sx<<sy<<" ";
	return sx + sy - max(sx * px , sy * py);
	
}
int main() {
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   //int T;cin>>T;while(T--)solve();
    cin>>n;
    for(int i = 1 ; i <= n ; i++){
    	cin>>a[i].first>>a[i].second;
    	if(a[i].first == 0) a[i].first += eps;
    	else if(a[i].first == 1) a[i].first -= eps;
    }
    sort(a + 1 , a + 1 + n , greater());
    for(int i = 1 ; i <= n ; i++) s[i] = s[i - 1] + a[i].second;
	//cout<<calc(1 , 3);
    double res = 0;
    for(int i = 1 ; i <= n ; i++){
    	int l = i + 1;
    	int r = n;
    	//cout<<i<<":\n";
    	//cout<<l<<" "<<r<<" \n";
    	while(l < r){
    		int lmid = l + (r - l) / 3;
    		int rmid = r - (r - l) / 3;
    		res = max({res , calc(i , lmid) , calc(i , rmid)});    
    		//cout<<lmid<<" "<<rmid<<"\n";
    		if(calc(i , lmid) >= calc(i , rmid)) l = lmid + 1;
    		else r = rmid - 1;
    	}
    	//cout<<l<<" "<<r<<" \n";
    	//cout<<calc(i , l);
    	//cout<<calc(i , r);
    	//cout<<endl;
    	res = max({res , calc(i , l) , calc(i , r)});    		
    }
    
    //10 / 3
    //2.5
    //2
    
    
    printf("%.7f" , res); 
    
    
}


//5 4 3 2 1
//5 4 3 2 1

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5912kb

input:

2
1 15
0 10

output:

10.0000000

result:

ok found '10.0000000', expected '10.0000000', error '0.0000000'

Test #2:

score: 0
Accepted
time: 1ms
memory: 6028kb

input:

3
0.4 100
0.5 100
0.6 100

output:

33.3333333

result:

ok found '33.3333333', expected '33.3333333', error '0.0000000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 6024kb

input:

1
0 1

output:

0.0000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

score: 0
Accepted
time: 1ms
memory: 6080kb

input:

2
1 0
1 100

output:

0.0000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 5956kb

input:

1
0.5 100

output:

0.0000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 6060kb

input:

3
0.4 100
0.6 100
0.6 100

output:

33.3333333

result:

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