답안 #485194

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485194 2021-11-06T14:07:42 Z Neos Balloons (CEOI11_bal) C++14
100 / 100
138 ms 4932 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define task "bongbong"
#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i, l, r) for( ll i = (l) ; i < (r) ; i++ )
#define forb(i, r, l) for( ll i = (r) ; i >= (l) ; i-- )
#define numBit(x) (__builtin_popcountll(1ll * (x)))
#define getBit(x, i) ((x) >> (i) & 1)
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define ar array
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define debug(x) cerr << #x << " = " << x << '\n';

const int N = 2e5 + 7;

int n;
double p[N], r[N];
stack<int> st;

int main() {
    scanf("%d", &n);
    forw(i, 0, n) {
        scanf("%lf %lf", &p[i], &r[i]);
        while (sz(st)) {
            int j = st.top();
            r[i] = min(r[i], (p[j] - p[i]) * (p[j] - p[i]) / (4 * r[j]));
            if (r[i] >= r[j]) st.pop(); else break;
        }
        st.push(i);
        printf("%.3lf\n", r[i]);
    }
    return 0;
}

Compilation message

bal.cpp: In function 'int main()':
bal.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d", &n);
      |     ~~~~~^~~~~~~~~~
bal.cpp:43:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |         scanf("%lf %lf", &p[i], &r[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB 10 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB 2 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB 505 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 332 KB 2000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 712 KB 20000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1520 KB 50000 numbers
2 Correct 30 ms 1364 KB 49912 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 76 ms 2636 KB 100000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 3056 KB 115362 numbers
2 Correct 71 ms 2864 KB 119971 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 123 ms 4008 KB 154271 numbers
2 Correct 131 ms 4628 KB 200000 numbers
# 결과 실행 시간 메모리 Grader output
1 Correct 138 ms 4932 KB 200000 numbers
2 Correct 120 ms 4608 KB 199945 numbers