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;
int N, M, D;
int reponse(vector<int> vals) {
int n = vals.size();
int maxicur = 0;
for (int i = 0; i < n; i ++) {
for (int j = i; j < n; j ++) {
maxicur = max(maxicur, (j - i) * D - (vals[j] - vals[i]));
}
}
return maxicur;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N >> M >> D;
vector<int> vals;
for (int i = 0; i < N; i ++) {
int val; cin >> val;
vals.push_back(val);
}
for (int i = 0; i < M; i ++) {
int val; cin >> val;
vals.push_back(val);
sort(vals.begin(), vals.end());
cout << (double) reponse(vals) / 2 << " ";
}
}
# | 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... |