QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725909#8037. Gambler's RuingjlcccWA 1ms8080kbC++201.4kb2024-11-08 20:36:432024-11-08 20:36:43

Judging History

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

  • [2024-11-08 20:36:43]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8080kb
  • [2024-11-08 20:36:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
typedef pair<ll, ll> pll;
const ll INF = 0x3f3f3f3f;
const ll MO9 = 998244353;
const ll MO1 = 1e9 + 7;
const ll MO = MO9;
const int N = 5e5 + 5;
ll n, m;
ll s[N];
long double p[N];
struct node {
  long double p;
  ll c;
} a[N], b[N];
void solve() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> b[i].p >> b[i].c;
  sort(b + 1, b + n + 1, [=](node a, node b) { return a.p > b.p; });
  int t = 0;
  b[0].p = -1.0;
  for (int i = 1; i <= n; i++) {
    if (b[i].p == b[i - 1].p) {
      a[t].c += b[i].c;
    } else
      a[++t] = b[i];
  }
  n = t;
  for (int i = 1; i <= n; i++) {
    // cin>>s[i];
    s[i] = a[i].c;
    s[i] += s[i - 1];
    p[i] = a[i].p;
  }
  long double ans = 0;
  for (int i = 1; i <= n; i++) {
    long double tot = 1.0 * s[i] / p[i];
    // cout<<tot<<'\n';
    int res = n;
    int l = i + 1, r = n;
    while (l <= r) {
      int mid = l + r >> 1;
      if (1.0 * (s[n] - s[mid - 1]) <= tot * (1.0 - p[mid])) {
        res = mid;
        ans = max(ans, s[n] - s[mid - 1] + s[i] - tot);
        r = mid - 1;
      } else
        l = mid + 1;
    }
  }
  cout << fixed << setprecision(9) << ans << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int ttt = 1;
  // cin>>ttt;
  while (ttt--) solve();
  return 0;
}

詳細信息

Test #1:

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

input:

2
1 15
0 10

output:

10.000000000

result:

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

Test #2:

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

input:

3
0.4 100
0.5 100
0.6 100

output:

33.333333333

result:

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

Test #3:

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

input:

1
0 1

output:

0.000000000

result:

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

Test #4:

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

input:

2
1 0
1 100

output:

0.000000000

result:

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

Test #5:

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

input:

1
0.5 100

output:

0.000000000

result:

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

Test #6:

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

input:

3
0.4 100
0.6 100
0.6 100

output:

0.000000000

result:

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

Test #7:

score: -100
Wrong Answer
time: 0ms
memory: 8016kb

input:

3
0.2 100
0.2 100
0.8 100

output:

0.000000000

result:

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