Submission #865018

# Submission time Handle Problem Language Result Execution time Memory
865018 2023-10-24T02:17:26 Z wii Balloons (CEOI11_bal) C++17
70 / 100
88 ms 4436 KB
#include <bits/stdc++.h>
using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;

#define int ll
typedef pair<int, int> pii;

#define X first
#define Y second
#define gcd __gcd
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define bit(i, mask) ((mask) >> (i) & 1)
#define reset(x, val) memset(x, val, sizeof(x))
#define foru(i,a,b) for(int i = (a); i <= (b); ++i)
#define ford(i,a,b) for(int i = (a); i >= (b); --i)
#define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

template<typename T> bool maximize(T &res, const T &val) { if (res < val) { res = val; return true; } return false; }
template<typename T> bool minimize(T &res, const T &val) { if (val < res) { res = val; return true; } return false; }

const ll Linf = 0x3f3f3f3f3f3f3f3f;
const int Inf = 0x3f3f3f3f;
const ll Mod = 1e9 + 7;
const ll Mod2 = ll(1e9) + 9;
const int Lim = 1e6 + 5;
const int inv6 = 166666668;

/// ====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====*====

const int base = 3;
const int N = 1e5 + 5;
const int K = log2(N);
const int dx[] = {+1, -1, 0, 0};
const int dy[] = {0, 0, +1, -1};
const int block_size = sqrt(2e9) + 2;

int n;
ld x[N], r[N];

ld sqr(ld x) { return (ld)x * x; }
void solve() {
    cin >> n;

	stack<int> st;
	foru(i, 1, n) {
		cin >> x[i] >> r[i];

		if (i == 1) {
			
		} else {
			while (!st.empty()) {
				int j = st.top();
				minimize(r[i], sqr(x[i] - x[st.top()]) / r[st.top()] / 4.0);
				if (r[i] > r[j]) st.pop(); else break;
			}
		}

		cout << setprecision(3) << fixed << r[i] << "\n";

		st.push(i);
	}
}

signed main() {
    FastIO;

    #define task "test"
    if (fopen(task".inp", "r")) {
		freopen(task".inp", "r", stdin);
		freopen(task".out", "w", stdout);
	}

    int ntest = 1;
    // cin >> ntest;
    while (ntest--) {
        //cout << "Case " << q << ": " << "\n"; 
        solve();
        cout << "\n";
    }

    return 0;
}

/**  /\_/\
 *  (= ._.)
 *  / >TL \>AC
**/

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:73:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   73 |   freopen(task".inp", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:74:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   74 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2396 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2396 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 17 ms 2648 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 42 ms 3152 KB 50000 numbers
2 Correct 39 ms 3156 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 84 ms 4436 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Incorrect 83 ms 4436 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 4432 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 88 ms 4176 KB Unexpected end of file - double expected
2 Halted 0 ms 0 KB -