답안 #677427

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
677427 2023-01-03T09:43:46 Z stanislavpolyn Measures (CEOI22_measures) C++17
0 / 100
1500 ms 468 KB
#include <bits/stdc++.h>

#define fr(i, a, b) for (int i = (a); i <= (b); ++i)
#define rf(i, a, b) for (int i = (a); i >= (b); --i)
#define fe(x, y) for (auto& x : y)

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define all(x) (x).begin(), (x).end()
#define pw(x) (1LL << (x))
#define sz(x) (int)(x).size()

using namespace std;

mt19937_64 rng(228);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define fbo find_by_order
#define ook order_of_key

template <typename T>
bool umn(T& a, T b) {
    return a > b ? (a = b, 1) : 0;
}
template <typename T>
bool umx(T& a, T b) {
    return a < b ? (a = b, 1) : 0;
}

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
using ve = vector<T>;

const int N = 3e5 + 5;

int n, m, d;
int a[N];
int b[N];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios::sync_with_stdio(0);
    cin.tie(0);
#endif

    cin >> n >> m >> d;

    d *= 2;

    fr (i, 1, n) {
        cin >> a[i];
        a[i] *= 2;
    }

    fr (i, 1, m) {
        int x;
        cin >> x;
        x *= 2;
        a[++n] = x;
        sort(a + 1, a + 1 + n);

        auto possible = [&](ll t) {
            fr (i, 1, n) b[i] = a[i];

            fr (i, 1, n) {
                int have = t;
                if (i > 1) {
                    int x = b[i] - b[i - 1];
                    if (x < d) {
                        if (d - x > t) {
                            return 0;
                        }
                        have -= max(0, d - x);
                        b[i] = b[i - 1] + d;
                    }
                }
                if (i == 1 || b[i] - b[i - 1] > d) {
                    if (i == 1) b[i] -= t;
                    else b[i] -= min(b[i] - b[i - 1] - d, have);
                }
            }
            return 1;
        };

        ll l = 0;
        ll r = 4e9;
        while (l < r) {
            ll mid = l + ((r - l) >> 1);
            if (possible(mid)) {
                r = mid;
            } else {
                l = mid + 1;
            }
        }
        assert(possible(l));

        cout << l / 2;
        if (l % 2) cout << ".5";
        cout << "\n";
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 4 ms 352 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 340 KB Output is correct
8 Incorrect 3 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 340 KB Output is correct
2 Correct 3 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 4 ms 340 KB Output is correct
5 Correct 4 ms 352 KB Output is correct
6 Correct 3 ms 340 KB Output is correct
7 Correct 4 ms 340 KB Output is correct
8 Incorrect 3 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1580 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1580 ms 468 KB Time limit exceeded
2 Halted 0 ms 0 KB -