Submission #537914

# Submission time Handle Problem Language Result Execution time Memory
537914 2022-03-15T21:14:37 Z theysoldtheworld Sure Bet (CEOI17_sure) C++14
60 / 100
2000 ms 4792 KB
#include <bits/stdc++.h>

using namespace std;

double Get(vector<double> a , vector<double> b) {
  int n = (int)a.size();
  double h = 0 , t = 0;
  double ans = 0;
  int id = 0;
  for (int i = 0 ; i < n ; i++) {
    h += a[i];
    double new_t = t - (i + 1);
    int add = 0;
    while (id < n && min(h - add , new_t) < ans) {
      add += 1;  
      new_t += b[id];
      id += 1;
    }
    t = 0;
    id = 0;
    ans = max(ans , min(h - add , new_t));
  }
  return ans;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<double> a(n) , b(n);
  for (int i = 0 ; i < n ; i++) {
    cin >> a[i] >> b[i];
    a[i] -= 1; 
    b[i] -= 1;
  }
  sort(a.rbegin() , a.rend());
  sort(b.rbegin() , b.rend());
  double ans = max(Get(a , b) , Get(b , a));
  cout << fixed << setprecision(4) << ans << '\n';
  return 0; 
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 360 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 216 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 216 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 3 ms 336 KB Output is correct
13 Correct 3 ms 340 KB Output is correct
14 Correct 2 ms 340 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 3 ms 360 KB Output is correct
17 Execution timed out 2088 ms 4792 KB Time limit exceeded
18 Halted 0 ms 0 KB -