Submission #35890

# Submission time Handle Problem Language Result Execution time Memory
35890 2017-12-02T03:58:00 Z funcsr Sure Bet (CEOI17_sure) C++14
100 / 100
149 ms 3576 KB
#include <iostream>
#include <vector>
#include <algorithm>
#define pb push_back
#define all(xs) xs.begin(), xs.end()
#define rep(i, n) for (int i=0; i<(n); i++)
using namespace std;

int N;
long long A[100000], B[100000];

int read_as_int() {
  string s;
  cin >> s;
  int ret = 0;
  bool after = false;
  string t = "";
  for (char c : s) {
    if (c == '.') {
      after = true;
      continue;
    }
    if (after) t += c;
    else ret = 10*ret + (int)(c-'0');
  }
  while (t.size() < 4) t += '0';
  return 10000*ret + stoi(t);
}

signed main() {
  cin >> N;
  rep(i, N) {
    A[i] = read_as_int();
    B[i] = read_as_int();
  }
  sort(A, A+N, greater<long long>());
  sort(B, B+N, greater<long long>());
  rep(i, N-1) A[i+1] += A[i];
  rep(i, N-1) B[i+1] += B[i];
  int p = 0;
  long long m = 0, s = 0;
  rep(a, N) {
    while (p < N && B[p] < A[a]) {
      s = max(s, B[p] - 10000LL*(p+1));
      p++;
    }
    m = max(m, s-10000LL*(a+1));
    if (p < N) {
      m = max(m, A[a] - 10000LL*(p+1+a+1));
    }
  }
  printf("%.4lf\n", (double)m/10000.0);
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3576 KB Output is correct
2 Correct 0 ms 3576 KB Output is correct
3 Correct 0 ms 3576 KB Output is correct
4 Correct 0 ms 3576 KB Output is correct
5 Correct 0 ms 3576 KB Output is correct
6 Correct 0 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3576 KB Output is correct
2 Correct 0 ms 3576 KB Output is correct
3 Correct 0 ms 3576 KB Output is correct
4 Correct 0 ms 3576 KB Output is correct
5 Correct 0 ms 3576 KB Output is correct
6 Correct 0 ms 3576 KB Output is correct
7 Correct 0 ms 3576 KB Output is correct
8 Correct 0 ms 3576 KB Output is correct
9 Correct 0 ms 3576 KB Output is correct
10 Correct 0 ms 3576 KB Output is correct
11 Correct 0 ms 3576 KB Output is correct
12 Correct 0 ms 3576 KB Output is correct
13 Correct 0 ms 3576 KB Output is correct
14 Correct 0 ms 3576 KB Output is correct
15 Correct 0 ms 3576 KB Output is correct
16 Correct 0 ms 3576 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 3576 KB Output is correct
2 Correct 0 ms 3576 KB Output is correct
3 Correct 0 ms 3576 KB Output is correct
4 Correct 0 ms 3576 KB Output is correct
5 Correct 0 ms 3576 KB Output is correct
6 Correct 0 ms 3576 KB Output is correct
7 Correct 0 ms 3576 KB Output is correct
8 Correct 0 ms 3576 KB Output is correct
9 Correct 0 ms 3576 KB Output is correct
10 Correct 0 ms 3576 KB Output is correct
11 Correct 0 ms 3576 KB Output is correct
12 Correct 0 ms 3576 KB Output is correct
13 Correct 0 ms 3576 KB Output is correct
14 Correct 0 ms 3576 KB Output is correct
15 Correct 0 ms 3576 KB Output is correct
16 Correct 0 ms 3576 KB Output is correct
17 Correct 109 ms 3576 KB Output is correct
18 Correct 109 ms 3576 KB Output is correct
19 Correct 119 ms 3576 KB Output is correct
20 Correct 143 ms 3576 KB Output is correct
21 Correct 126 ms 3576 KB Output is correct
22 Correct 106 ms 3576 KB Output is correct
23 Correct 126 ms 3576 KB Output is correct
24 Correct 109 ms 3576 KB Output is correct
25 Correct 113 ms 3576 KB Output is correct
26 Correct 149 ms 3576 KB Output is correct