#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <vector>
using namespace std;
const int MX = 2e5 + 15;
int n, m, d;
int a[MX], b[MX];
void go() {
for(int j = 0; j < m; j++) {
int ind = -1;
for(int i = 0; i < n; i++) {
if(a[i] > b[j]) {
ind = i;
break;
}
}
if(ind == -1) ind = n;
for(int i = n; i > ind; i--) a[i] = a[i - 1];
a[ind] = b[j];
n++;
long long mx = 0, mn = 1e18, cur = 0;
for(int i = 0; i < n - 1; i++) {
cur += a[i + 1] - a[i] - d;
mn = min(mn, cur - mx);
mx = max(mx, cur);
}
if(mn > 0) cout << "0\n";
else{
cout << -mn / 2;
if(mn % 2)cout << ".5\n";
else cout << "\n";
}
}
}
int main() {
cin >> n >> m >> d;
for(int i = 0; i < n; i++) cin >> a[i];
for(int i = 0; i < m; i++) cin >> b[i];
sort(a, a + n);
go();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
70 ms |
1172 KB |
Output is correct |
10 |
Correct |
73 ms |
3120 KB |
Output is correct |
11 |
Correct |
61 ms |
3004 KB |
Output is correct |
12 |
Correct |
74 ms |
2940 KB |
Output is correct |
13 |
Correct |
52 ms |
2520 KB |
Output is correct |
14 |
Correct |
64 ms |
2900 KB |
Output is correct |
15 |
Correct |
56 ms |
2256 KB |
Output is correct |
16 |
Correct |
61 ms |
2932 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1562 ms |
1420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1562 ms |
1420 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |