답안 #914625

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
914625 2024-01-22T12:27:26 Z NoLove Balloons (CEOI11_bal) C++14
0 / 100
137 ms 7112 KB
/**
 *    author : Lăng Trọng Đạt
 *    created: 22-01-2024 
**/
#include <bits/stdc++.h>
using namespace std;
#ifndef LANG_DAT
#define db(...) ;
#endif // LANG_DAT
#define int long long
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
using pii = pair<int, int>;
using vi = vector<int>;
#define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
void mx(int& a, int b) { if (b > a) a = b; }
void mi(int& a, int b) { if (b < a) a = b; }
#define si(x) (int)(x.size())
const int INF = 1e18;
const int MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;
int x[MAXN];
double r[MAXN]; // r[i]: final radius of balloon i
int n;

double mx_radius(int i, int j) {
    if (i == 0) return INF;
    return (double)(x[i] - x[j])*(x[i] - x[j]) / 4 / r[i];
}

int32_t main() {
    cin.tie(0)->sync_with_stdio(0);
    if (fopen("hi.inp", "r")) {
        freopen("hi.inp", "r", stdin);
//        freopen("hi.out", "w", stdout);
    } 

    vi s = {0};
    r[0] = INF;
    x[0] = -1e8;
    cin >> n;
    FOR(i, 1, n) {
        cin >> x[i] >> r[i];
        db(i, s, mx_radius(s.back(), i))
        while (mx_radius(s.back(), i) < r[i] or r[i] >= r[s.back()]) {
            r[i] = min(r[i], mx_radius(s.back(), i));
            db(i, s.back(), r[i])
            s.pop_back();
            db(mx_radius(s.back(), i), s.back())
        }
        s.push_back(i);
        cout << setprecision(4) << r[i] << "\n";
    }
}

Compilation message

bal.cpp: In function 'int32_t main()':
bal.cpp:18:31: warning: unnecessary parentheses in declaration of 'i' [-Wparentheses]
   18 | #define FOR(i, a, b) for (int (i) = a; (i) <= (b); i++)
      |                               ^
bal.cpp:46:5: note: in expansion of macro 'FOR'
   46 |     FOR(i, 1, n) {
      |     ^~~
bal.cpp:38:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |         freopen("hi.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB 5th numbers differ - expected: '17.1630000000', found: '99.0000000000', error = '81.8370000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2392 KB 1st numbers differ - expected: '247294217.0000000000', found: '247300000.0000000000', error = '5783.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2548 KB 3rd numbers differ - expected: '0.0420000000', found: '3.0000000000', error = '2.9580000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB 2nd numbers differ - expected: '122.0020000000', found: '122.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 14 ms 2908 KB 50th numbers differ - expected: '159.0020000000', found: '159.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 49 ms 3616 KB 1st numbers differ - expected: '15399.0000000000', found: '15400.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 70 ms 4748 KB 285th numbers differ - expected: '7629.0020000000', found: '7629.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 81 ms 5124 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0000000000', error = '0.0050000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 118 ms 6228 KB 164th numbers differ - expected: '1698.0020000000', found: '1698.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 137 ms 7112 KB 248th numbers differ - expected: '2694.0020000000', found: '2694.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -