Submission #763790

# Submission time Handle Problem Language Result Execution time Memory
763790 2023-06-22T21:08:30 Z MilosMilutinovic Measures (CEOI22_measures) C++14
24 / 100
1500 ms 3132 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, m, d, a[N], b[N];
bool check(long double x) {
    long double prv = a[1] - x;
    for (int i = 2; i <= n; i++) {
        long double L = a[i] - x;
        long double R = a[i] + x;
        long double pos = max(L, prv + d);
        if (pos > R) {
            return false;
        }
        prv = pos;
    }
    return true;
}
int main() {
    scanf("%d%d%d", &n, &m, &d);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1; i <= m; i++) {
        scanf("%d", &b[i]);
    }
    for (int i = 1; i <= m; i++) {
        a[++n] = b[i];
        sort(a + 1, a + n + 1);
        long long low = 0, high = 1e17, ans = 1e17;
        while (low <= high) {
            long long mid = low + (high - low) / 2;
            if (check(mid)) {
                ans = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        if (ans > 0 && check(ans - 0.5))
            printf("%lld.5 ", ans - 1);
        else
            printf("%lld ", ans);
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:19:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     scanf("%d%d%d", &n, &m, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:24:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 7 ms 212 KB Output is correct
3 Correct 7 ms 212 KB Output is correct
4 Correct 7 ms 320 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 7 ms 212 KB Output is correct
8 Correct 7 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 212 KB Output is correct
2 Correct 7 ms 212 KB Output is correct
3 Correct 7 ms 212 KB Output is correct
4 Correct 7 ms 320 KB Output is correct
5 Correct 6 ms 212 KB Output is correct
6 Correct 6 ms 212 KB Output is correct
7 Correct 7 ms 212 KB Output is correct
8 Correct 7 ms 212 KB Output is correct
9 Correct 685 ms 3008 KB Output is correct
10 Correct 763 ms 3012 KB Output is correct
11 Correct 655 ms 3044 KB Output is correct
12 Correct 735 ms 3016 KB Output is correct
13 Correct 650 ms 2556 KB Output is correct
14 Correct 663 ms 2992 KB Output is correct
15 Correct 682 ms 2456 KB Output is correct
16 Correct 634 ms 3132 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1560 ms 1220 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1560 ms 1220 KB Time limit exceeded
2 Halted 0 ms 0 KB -