Submission #701325

# Submission time Handle Problem Language Result Execution time Memory
701325 2023-02-20T22:54:47 Z PurpleCrayon Measures (CEOI22_measures) C++17
0 / 100
1500 ms 4936 KB
#include <bits/stdc++.h>
using namespace std;
 
#define sz(v) int(v.size())
#define ar array
typedef long long ll;
const int N = 2e5+10, MOD = 998244353;
const ll INF = 1e18+10;

void solve() {
    int n, m, d; cin >> n >> m >> d;
    vector<int> a(n); for (auto& x : a) cin >> x;
    vector<int> b(m); for (auto& x : b) cin >> x;

    vector<pair<int, int>> v;
    for (int i = 0; i < n; i++) {
        v.emplace_back(a[i], i);
    }
    for (int i = 0; i < m; i++) {
        v.emplace_back(b[i], n + i);
    }

    sort(v.begin(), v.end());

    vector<int> loc_a(n), loc_b(m);
    for (int i = 0; i < n + m; i++) {
        if (v[i].second < n) {
            loc_a[v[i].second] = i;
        } else {
            loc_b[v[i].second - n] = i;
        }
    }

    vector<ll> val(n + m, INF);
    for (int i = 0; i < n; i++) {
        val[loc_a[i]] = (long long) d * loc_a[i] - a[i];
    }

    for (int i = 0; i < m; i++) {
        val[loc_b[i]] = (long long) d * loc_b[i] - b[i];

        ll ans = 0;
        for (int x = 0; x < n + m; x++) if (val[x] != INF) {
            for (int y = x + 1; y < n + m; y++) if (val[y] != INF) {
                ans = max(ans, val[y] - val[x]);
            }
        }
        cout << (long double) ans / 2 << ' ';
    }
    cout << '\n';
}
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int T = 1;
    // cin >> T;
    while (T--) solve();
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 340 KB Output is correct
2 Incorrect 23 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 20 ms 340 KB Output is correct
2 Incorrect 23 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1573 ms 4936 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1573 ms 4936 KB Time limit exceeded
2 Halted 0 ms 0 KB -