#include <bits/stdc++.h>
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using ld = long double;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
signed main() {
ll n, m, d;
cin >> n >> m >> d;
vector<ll> a(n);
for(ll &x : a) cin >> x;
sort(a.begin(), a.end());
while(m--) {
ll x;
cin >> x;
a.push_back(x);
sort(a.begin(), a.end());
ll ans = 0;
vector<ll> vec; vec.push_back(-1e18);
for(ll &x : a) vec.push_back(x);
for(int i=1; i<vec.size(); i++) {
if(vec[i] - vec[i-1] < d) ans = max(ans, vec[i-1] - vec[i] + d);
vec[i] = max(vec[i-1] + d, vec[i]);
}
if(ans % 2 == 0) {
cout << ans / 2 << " ";
} else {
cout << ans / 2 << ".5 ";
}
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:33:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | for(int i=1; i<vec.size(); i++) {
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
154 ms |
7552 KB |
Output is correct |
10 |
Correct |
202 ms |
7732 KB |
Output is correct |
11 |
Correct |
95 ms |
7576 KB |
Output is correct |
12 |
Correct |
208 ms |
7544 KB |
Output is correct |
13 |
Correct |
89 ms |
7084 KB |
Output is correct |
14 |
Correct |
174 ms |
7500 KB |
Output is correct |
15 |
Correct |
126 ms |
6880 KB |
Output is correct |
16 |
Correct |
133 ms |
7548 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1572 ms |
1112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
1572 ms |
1112 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |