Submission #793010

#TimeUsernameProblemLanguageResultExecution timeMemory
793010WLZMeasures (CEOI22_measures)C++17
59 / 100
182 ms7004 KiB
#include <bits/stdc++.h>
using namespace std;

const long double eps = 1e-9;

int n, m, d;
vector<int> a, b;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> d;
  if (m <= 10) {
    a.resize(n); b.resize(m);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 0; i < m; i++) {
      cin >> b[i];
      a.push_back(b[i]);
      sort(a.begin(), a.end());
      long double e = a[0], ans = 0.0;
      for (int j = 1; j < (int) a.size(); j++) {
        long double reach = a[j] + ans;
        if (reach - e > d) {
          if (a[j] > e + d) e = max(e + d, a[j] - ans);
          else e += d;
        } else {
          long double tmp = ans;
          ans += (e + d - reach) / 2;
          e = a[j] + tmp + (e + d - reach) / 2;
        }
      }
      if (abs(ans - floor(ans)) < eps) cout << (long long) floor(ans) << ' ';
      else cout << fixed << setprecision(1) << ans << ' ';
    }
    cout << '\n';
  } else {
    a.resize(m); b.resize(m);
    cin >> a[0];
    cout << 0 << ' ';
    long double e = a[0], ans = 0.0;
    for (int j = 1; j < m; j++) {
      cin >> a[j];
      long double reach = a[j] + ans;
      if (reach - e > d) {
        if (a[j] > e + d) e = max(e + d, a[j] - ans);
        else e += d;
      } else {
        long double tmp = ans;
        ans += (e + d - reach) / 2;
        e = a[j] + tmp + (e + d - reach) / 2;
      }
      if (abs(ans - floor(ans)) < eps) cout << (long long) floor(ans) << ' ';
      else cout << fixed << setprecision(1) << ans << ' ';
    }
    cout << '\n';
  }
  return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...