#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() {
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
ll n, m, d;
cin >> n >> m >> d;
vector<ll> a(n);
for(ll &x : a) cin >> x;
sort(a.begin(), a.end());
if(!n) {
vector<ll> vec; vec.push_back(-1e18);
ll ans = 0;
int vec_size = 1;
while(m--) {
ll x; cin >> x;
vec_size++;
vec.push_back(x);
if(vec[vec_size-1] - vec[vec_size-2] < d) ans = max(ans, d - vec[vec_size-1] + vec[vec_size-2]);
vec[vec_size-1] = max(vec[vec_size-1], vec[vec_size-2] + d);
if(ans % 2 == 0) {
cout << ans / 2 << " ";
} else {
cout << ans / 2 << ".5 ";
}
}
return 0;
}
while(m--) {
ll x;
cin >> x;
a.push_back(x);
sort(a.begin(), a.end());
ll ans = 0;
vector<ll> vec;
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, d - vec[i] + vec[i-1]);
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:55:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
55 | for(int i=1; i<vec.size(); i++) {
| ~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
468 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
120 ms |
7576 KB |
Output is correct |
10 |
Correct |
168 ms |
7568 KB |
Output is correct |
11 |
Correct |
58 ms |
7616 KB |
Output is correct |
12 |
Correct |
178 ms |
7560 KB |
Output is correct |
13 |
Correct |
60 ms |
7116 KB |
Output is correct |
14 |
Correct |
119 ms |
7544 KB |
Output is correct |
15 |
Correct |
107 ms |
6884 KB |
Output is correct |
16 |
Correct |
63 ms |
7596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
5064 KB |
Output is correct |
2 |
Correct |
31 ms |
7052 KB |
Output is correct |
3 |
Correct |
33 ms |
6868 KB |
Output is correct |
4 |
Correct |
23 ms |
4824 KB |
Output is correct |
5 |
Correct |
27 ms |
6092 KB |
Output is correct |
6 |
Correct |
25 ms |
5064 KB |
Output is correct |
7 |
Correct |
27 ms |
6100 KB |
Output is correct |
8 |
Correct |
24 ms |
4820 KB |
Output is correct |
9 |
Correct |
27 ms |
4808 KB |
Output is correct |
10 |
Correct |
40 ms |
7116 KB |
Output is correct |
11 |
Correct |
26 ms |
5584 KB |
Output is correct |
12 |
Correct |
28 ms |
6600 KB |
Output is correct |
13 |
Correct |
24 ms |
4816 KB |
Output is correct |
14 |
Correct |
29 ms |
6604 KB |
Output is correct |
15 |
Correct |
27 ms |
6604 KB |
Output is correct |
16 |
Correct |
26 ms |
4312 KB |
Output is correct |
17 |
Correct |
27 ms |
6148 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
26 ms |
5064 KB |
Output is correct |
2 |
Correct |
31 ms |
7052 KB |
Output is correct |
3 |
Correct |
33 ms |
6868 KB |
Output is correct |
4 |
Correct |
23 ms |
4824 KB |
Output is correct |
5 |
Correct |
27 ms |
6092 KB |
Output is correct |
6 |
Correct |
25 ms |
5064 KB |
Output is correct |
7 |
Correct |
27 ms |
6100 KB |
Output is correct |
8 |
Correct |
24 ms |
4820 KB |
Output is correct |
9 |
Correct |
27 ms |
4808 KB |
Output is correct |
10 |
Correct |
40 ms |
7116 KB |
Output is correct |
11 |
Correct |
26 ms |
5584 KB |
Output is correct |
12 |
Correct |
28 ms |
6600 KB |
Output is correct |
13 |
Correct |
24 ms |
4816 KB |
Output is correct |
14 |
Correct |
29 ms |
6604 KB |
Output is correct |
15 |
Correct |
27 ms |
6604 KB |
Output is correct |
16 |
Correct |
26 ms |
4312 KB |
Output is correct |
17 |
Correct |
27 ms |
6148 KB |
Output is correct |
18 |
Incorrect |
29 ms |
6088 KB |
Output isn't correct |
19 |
Halted |
0 ms |
0 KB |
- |