Submission details
Task:Snake mall
Sender:ind1f
Submission time:2025-09-08 17:11:02 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:37:11: error: expected ';' before ':' token
   37 |       ll++:
      |           ^
      |           ;

Code

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 5;

int n;
int a[N];
pair<int, int> b[N];
long double ans[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[i] = make_pair(a[i], i);
  }
  long long tot = 0;
  sort(b + 1, b + n + 1);
  if (n == 1) {
    cout << 0 << '\n';
    cout << 0 << '\n';
    return 0;
  }
  if (n == 2) {
    cout << 0 << '\n';
    cout << 0 << ' ' << -a[2] << '\n';
    return 0;
  }
  long double l = 1.0F * b[1].first / 2, r = 1.0F * b[1].first / 2;
  ans[b[1].second] = 0;
  int ll = 0, rr = 0;
  for (int i = 2; i <= n; i++) {
    if (l <= r) {
      ll++:
      tot += l;
      l += b[i].first;
      ans[b[i].second] = -l;
    } else {
      rr++;
      tot += r;
      ans[b[i].second] = r;
      r += b[i].first;
    }
  }
  assert(abs(ll - rr) <= 1);
  cout << fixed << setprecision(6) << 1.0F * tot / n << '\n';
  for (int i = 1; i <= n; i++) {
    cout << fixed << setprecision(6) << ans[i] << ' ';
  }
  return 0;
}