Submission #722307

# Submission time Handle Problem Language Result Execution time Memory
722307 2023-04-11T18:03:59 Z Pety Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

ifstream fin ("gadfadar2.in");
ofstream fout ("gadfadar2.out");

int n;
double a[100002], b[100002];

double f (int na, int nb) {
  return min(a[na] - nb, b[nb] - na);
}

int main () 
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i] >> b[i];
    a[i] -= 1.0;
    b[i] -= 1.0;
  }
  sort(a + 1, a + n + 1, greater<double>());
  sort(b + 1, b + n + 1, greater<double>());
  for (int i = 1; i <= n; i++)
    a[i] += a[i - 1];
  for (int i = 1; i <= n; i++)
    b[i] += b[i - 1];
  double ans = -1e9;
  for (int i = 0; i <= n; i++) {
    double val = a[i];
    int st = 0, dr = n - 1, p = -1;
    while (st <= dr) {
      int mid = (st + dr) / 2;
      if (f(i, mid) < f(i, mid + 1)) {
        p = mid;
        st = mid + 1;
      }
      else
        dr = mid - 1;
    }
    ans = max(ans, f(i, p  + 1));
  }
  cout << fixed << setprecision(10) << ans;
  return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:33:12: warning: unused variable 'val' [-Wunused-variable]
   33 |     double val = a[i];
      |            ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -