Submission #831823

# Submission time Handle Problem Language Result Execution time Memory
831823 2023-08-20T15:46:22 Z QwertyPi Measures (CEOI22_measures) C++14
0 / 100
1500 ms 764 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MAXN = 2e5 + 11;

int n, m, d;
bool can(vector<int>& a, int t){
    int x0 = -(1LL << 31);
    for(auto x : a){
        x0 = max(x - t, x0 + d);
        if(x0 > x + t) return false;
    }
    return true;
}

int solve(vector<int>& a){
    sort(a.begin(), a.end());
    int lo = 0, hi = 1LL << 31;
    while(lo != hi){
        int mid = (lo + hi) / 2;
        if(can(a, mid)){
            hi = mid;
        }else{
            lo = mid + 1;
        }
    }
    return lo;
}

int32_t main(){
    cin >> n >> m >> d; d *= 2;
    vector<int> a; for(int i = 0; i < n; i++) { int v; cin >> v; v *= 2; a.push_back(v); }
    for(int i = 0; i < m; i++){
        int v; cin >> v; v *= 2; a.push_back(v);
        sort(a.begin(), a.end());
        int ans = solve(a);
        cout << ans / 2 << (ans % 2 ? ".5" : "") << ' ';
    }
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 472 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 2 ms 316 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 472 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 3 ms 340 KB Output is correct
4 Correct 3 ms 340 KB Output is correct
5 Correct 2 ms 316 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Incorrect 1 ms 340 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 764 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1563 ms 764 KB Time limit exceeded
2 Halted 0 ms 0 KB -