답안 #990979

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
990979 2024-06-01T02:48:55 Z chanhchuong123 Balloons (CEOI11_bal) C++14
10 / 100
95 ms 6324 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, int>> 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);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 8th numbers differ - expected: '8.7410000000', found: '9.0910000000', error = '0.3500000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 13th numbers differ - expected: '2.3960000000', found: '2.4500000000', error = '0.0540000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 3rd numbers differ - expected: '121.0000000000', found: '121.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 860 KB 44th numbers differ - expected: '165.0000000000', found: '165.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 26 ms 1888 KB 254th numbers differ - expected: '15129.9990000000', found: '15130.0010000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 54 ms 3412 KB 286th numbers differ - expected: '7633.9990000000', found: '7634.0010000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 4016 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0070000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 80 ms 5188 KB 165th numbers differ - expected: '1698.9980000000', found: '1699.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 95 ms 6324 KB 249th numbers differ - expected: '2683.0090000000', found: '2683.0110000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -