Submission #871008

#TimeUsernameProblemLanguageResultExecution timeMemory
871008Trisanu_DasSeesaw (JOI22_seesaw)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int A[200005], n; long long pref[200005]; long double ans; long double calc(int l, int r) { return (long double)(pref[r] - pref[l - 1]) / (r - l + 1); } long double solve(long double max_r) { int l = 1, r = n; ld tl = calc(l, r), tr = calc(l, r); while (l < r) { long doube tll = min(tl, calc(l + 1, r)), tlr = max(tr, calc(l + 1, r)); if (tlr <= max_r) l++; else r--; tl = min(tl, calc(l, r)); tr = max(tr, calc(l, r)); if (tr - tl >= ans) return tr - tl; } return tr - tl; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> n; for (int i = 1; i <= n; i++) { cin >> A[i]; pref[i] = pref[i - 1] + A[i]; } ans = A[n] - A[1]; for (int l = 1; l <= n; l++) for (int r = l; r <= n; r++) ans = min(ans, solve(calc(l, r))); cout << setprecision(10) << fixed << ans << '\n'; }

Compilation message (stderr)

seesaw.cpp: In function 'long double solve(long double)':
seesaw.cpp:14:2: error: 'ld' was not declared in this scope; did you mean 'l'?
   14 |  ld tl = calc(l, r), tr = calc(l, r);
      |  ^~
      |  l
seesaw.cpp:16:14: error: expected initializer before 'tll'
   16 |   long doube tll = min(tl, calc(l + 1, r)), tlr = max(tr, calc(l + 1, r));
      |              ^~~
seesaw.cpp:17:7: error: 'tlr' was not declared in this scope
   17 |   if (tlr <= max_r) l++;
      |       ^~~
seesaw.cpp:19:3: error: 'tl' was not declared in this scope; did you mean 'l'?
   19 |   tl = min(tl, calc(l, r));
      |   ^~
      |   l
seesaw.cpp:20:3: error: 'tr' was not declared in this scope; did you mean 'r'?
   20 |   tr = max(tr, calc(l, r));
      |   ^~
      |   r
seesaw.cpp:23:9: error: 'tr' was not declared in this scope; did you mean 'r'?
   23 |  return tr - tl;
      |         ^~
      |         r
seesaw.cpp:23:14: error: 'tl' was not declared in this scope; did you mean 'l'?
   23 |  return tr - tl;
      |              ^~
      |              l