QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#524600 | #8037. Gambler's Ruin | MCdyc | WA | 0ms | 3916kb | C++23 | 1.2kb | 2024-08-19 20:46:43 | 2024-08-19 20:46:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()
#define int long long
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector<pair<double, int>> a;
int sum = 0;
int cntx = 0;
int cnty = 0;
map<double, int> mp;
for (int i = 0; i < n; i++)
{
double x;
int y;
cin >> x >> y;
mp[x] += y;
}
for (auto &it : mp)
a.emplace_back(it);
a.emplace_back(1, 0);
a.emplace_back(0, 0);
sort(all(a), greater());
double ans = 0;
n = mp.size();
int r = n + 1;
double sy = 0;
for (int i = 1; a[i].first > 0 && i <= n; i++)
{
cntx += a[i].second;
double x = 1 / a[i].first;
double sx = x * cntx;
while (sy <= sx && a[r].first < 1 && r > 0)
{
ans = max(ans, cnty + cntx - sx);
cnty += a[r].second;
double y = 1 / (1 - a[r].first);
sy = y * cnty;
r--;
}
ans = max(ans, cnty + cntx - max(sx, sy));
}
cout << fixed << setprecision(12) << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3916kb
input:
2 1 15 0 10
output:
0.000000000000
result:
wrong answer 1st numbers differ - expected: '10.0000000', found: '0.0000000', error = '1.0000000'