This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout<<fixed<<setprecision(15);
auto print = [&](ll x){
if (x % 2 == 0){
cout<<x / 2<<" ";
}
else {
cout<<(x - 1) / 2<<".5 ";
}
};
int n, m, d; cin>>n>>m>>d;
vector<int> a;
for (int i = 1; i <= n; i++){
int x; cin>>x;
a.pb(x);
}
if (m <= 10){
while (m--){
int x; cin>>x;
a.pb(x);
sort(a.begin(), a.end());
vector<ll> f(a.size());
f[0] = a[0];
for (int i = 1; i < a.size(); i++){
f[i] = max((ll) a[i], f[i - 1] + d);
}
ll out = 0;
for (int i = 0; i < f.size(); i++){
out = max(out, f[i] - a[i]);
}
print(out);
}
return 0;
}
ll p = -d, out = 0;
for (int i = 0; i < m; i++){
int x; cin>>x;
p = max((ll) x, p + d);
out = max(out, p - x);
print(out);
}
}
Compilation message (stderr)
Main.cpp: In function 'int main()':
Main.cpp:39:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | for (int i = 1; i < a.size(); i++){
| ~~^~~~~~~~~~
Main.cpp:44:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | for (int i = 0; i < f.size(); i++){
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |