Submission #990980

# Submission time Handle Problem Language Result Execution time Memory
990980 2024-06-01T02:49:29 Z chanhchuong123 Balloons (CEOI11_bal) C++14
100 / 100
92 ms 7132 KB
#include<bits/stdc++.h>
using namespace std;

const bool multiTest = false;
#define task ""
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)

template<typename T1, typename T2> bool mini(T1 &a, T2 b) {
	if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maxi(T1 &a, T2 b) {
	if (a < b) a = b; else return 0; return 1;
}

const int MAX = 200020;
int n;
int x[MAX];
int r[MAX];
stack<pair<int, double>> st;

double dis(int x1, double r1, int x2) {
    return 1.0 * (x1 - x2) * (x1 - x2) / (4 * r1);
}

void process(void) {
    cin >> n;
    cout << setprecision(3) << fixed;
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
        cin >> r[i];
        double ans = r[i];
        while (st.size()) {
            mini(ans, dis(st.top().fi, st.top().se, x[i]));
            if (st.top().se <= ans) st.pop(); else break;
        }
        st.push(make_pair(x[i], ans));
        cout << ans << '\n';
    }
}

int main(void) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	if (fopen(task".inp", "r")) {
		freopen(task".inp", "r",  stdin);
		freopen(task".out", "w", stdout);
	}

	int nTest = 1; if (multiTest) cin >> nTest;
	while (nTest--) {
		process();
	}

	return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:49:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   49 |   freopen(task".inp", "r",  stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:50:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   50 |   freopen(task".out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB 10 numbers
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB 2 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 505 numbers
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB 2000 numbers
# Verdict Execution time Memory Grader output
1 Correct 10 ms 604 KB 20000 numbers
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1220 KB 50000 numbers
2 Correct 22 ms 2128 KB 49912 numbers
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2140 KB 100000 numbers
# Verdict Execution time Memory Grader output
1 Correct 57 ms 2308 KB 115362 numbers
2 Correct 52 ms 4432 KB 119971 numbers
# Verdict Execution time Memory Grader output
1 Correct 80 ms 2900 KB 154271 numbers
2 Correct 87 ms 7020 KB 200000 numbers
# Verdict Execution time Memory Grader output
1 Correct 92 ms 3408 KB 200000 numbers
2 Correct 85 ms 7132 KB 199945 numbers