Submission #763782

# Submission time Handle Problem Language Result Execution time Memory
763782 2023-06-22T21:04:49 Z MilosMilutinovic Measures (CEOI22_measures) C++14
0 / 100
1500 ms 3036 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 10;
int n, m, d, a[N], b[N];
bool check(double x) {
    sort(a + 1, a + n + 1);
    double prv = -1e9;
    for (int i = 1; i <= n; i++) {
        double L = a[i] - x;
        double R = a[i] + x;
        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];
        int low = 0, high = 1e9, ans = 1e9;
        while (low <= high) {
            int mid = (low + high) / 2;
            if (check(mid)) {
                ans = mid;
                high = mid - 1;
            } else {
                low = mid + 1;
            }
        }
        if (ans > 0 && check(ans - 0.5))
            printf("%d.5 ", ans - 1);
        else
            printf("%d ", ans);
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:20:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     scanf("%d%d%d", &n, &m, &d);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~
Main.cpp:25:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |         scanf("%d", &b[i]);
      |         ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 5 ms 324 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 8 ms 212 KB Output is correct
8 Incorrect 5 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 340 KB Output is correct
2 Correct 6 ms 340 KB Output is correct
3 Correct 5 ms 324 KB Output is correct
4 Correct 7 ms 340 KB Output is correct
5 Correct 6 ms 336 KB Output is correct
6 Correct 6 ms 340 KB Output is correct
7 Correct 8 ms 212 KB Output is correct
8 Incorrect 5 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1556 ms 3036 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1556 ms 3036 KB Time limit exceeded
2 Halted 0 ms 0 KB -