Submission #94251

# Submission time Handle Problem Language Result Execution time Memory
94251 2019-01-17T06:06:53 Z 1Khan Sure Bet (CEOI17_sure) C++14
100 / 100
85 ms 3704 KB
/// 1n  the  name  of  GOD

#include <bits/stdc++.h>

using   namespace        std;

#define ko               exit(0);
#define nl               '\n'
#define ios              ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz(s)            (int)s.size()
#define all(s)           s.begin(), s.end()
#define oll(s, n, c)     (s) + (c), s + (n) + c
#define pb               push_back
#define bb               begin()
#define ee               end()
#define ff               first
#define ss               second
#define pii              pair<int, int>
//#define for(i, l, r)  for(int (i) = (l); i <= (r); ++i)

typedef long long ll;
typedef double db;

const int N = 1e6 + 777;
const int M = INT_MAX;

int n;
double a[N], b[N];
double c, d;
int main(){

     ios

     cin >> n;
     for(int i = 1; i <= n; ++i){
          cin >> a[i] >> b[i];
     }
     sort(oll(a, n, 1));
     sort(oll(b, n, 1));
     reverse(oll(a, n, 1));
     reverse(oll(b, n, 1));
     int id = 0;
     int di = 0;
     double ans = 0;
     for(int i = 1; i <= 2 * n; ++i){
          if(c <= d){
               id++;
               c += (double)a[id];
          } else if(d < c){
               di++;
               d += (double)b[di];
          }
          ans = (double)max((db)ans, min((db)c - (double)i, (db)d - (double)i));
     }
     cout << fixed << setprecision(4) << (double)ans;
     return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 1 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 308 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 0 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 1 ms 376 KB Output is correct
5 Correct 1 ms 376 KB Output is correct
6 Correct 1 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 1 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 308 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 0 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 77 ms 1912 KB Output is correct
18 Correct 78 ms 1960 KB Output is correct
19 Correct 79 ms 1964 KB Output is correct
20 Correct 78 ms 2040 KB Output is correct
21 Correct 85 ms 3704 KB Output is correct
22 Correct 81 ms 3320 KB Output is correct
23 Correct 78 ms 3320 KB Output is correct
24 Correct 80 ms 3320 KB Output is correct
25 Correct 82 ms 3492 KB Output is correct
26 Correct 85 ms 3704 KB Output is correct