Submission #1108144

# Submission time Handle Problem Language Result Execution time Memory
1108144 2024-11-03T03:15:26 Z akamizane Balloons (CEOI11_bal) C++17
30 / 100
120 ms 6108 KB
#include<bits/stdc++.h>
 
using namespace std;
 
#define debug(...) 40

using ll = long long;
using pii = pair<int,int>;
using db = double;

#define el cout << '\n'
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
template <class T1, class T2>bool chmax(T1 &a, T2 b){return a < b ? a = b, 1 : 0;}
template <class T1, class T2>bool chmin(T1 &a, T2 b){return a > b ? a = b, 1 : 0;}
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int maxn = 2e5 + 5;

const ll mod = 1e9 + 7;

db calc(pair<db, db> b, db x){
  return (b.fi - x) * (b.fi - x) / (4 * b.se);
}

void solve(){
  int n;
  cin >> n;
  stack<pair<db, db>> s;
  vector<db> val(n);
  for (int i = 0; i < n; i++){
    double x, r;
    cin >> x >> r;
    double mi = r;
    while(s.size()){
      auto [x1, y1] = s.top();
      db val = calc({x1, y1}, x);
      chmin(mi, val);
      if (val > y1) s.pop();
      else break;
    }
    s.push({x, mi});
    val[i] = mi;
  }
  cout << setprecision(3) << fixed;
  for (auto v : val) cout << v << "\n";
}

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tests = 1;
  // cin >> tests;
  for (int _ = 1; _ <= tests; _++){
    cerr << "- Case #" << _ << ": \n";
    solve();
    el;
  }
  return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB 504th numbers differ - expected: '160.9360000000', found: '163.0000000000', error = '2.0640000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 860 KB 653rd numbers differ - expected: '96.2810000000', found: '123.0000000000', error = '26.7190000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 33 ms 1880 KB 50000 numbers
2 Incorrect 32 ms 2128 KB 49903rd numbers differ - expected: '443977872.4679999948', found: '1000000000.0000000000', error = '556022127.5320000648'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 3400 KB 14857th numbers differ - expected: '7169.6020000000', found: '7176.0000000000', error = '6.3980000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 74 ms 3912 KB 23610th numbers differ - expected: '1467.9600000000', found: '1471.0000000000', error = '3.0400000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 109 ms 5096 KB 12335th numbers differ - expected: '4957.2960000000', found: '4967.0000000000', error = '9.7040000000'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 6108 KB 8510th numbers differ - expected: '318.4980000000', found: '320.0000000000', error = '1.5020000000'
2 Halted 0 ms 0 KB -