답안 #1045122

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1045122 2024-08-05T17:10:41 Z nmts Balloons (CEOI11_bal) C++17
0 / 100
103 ms 7508 KB
#include <bits/stdc++.h>

#define file(name) freopen(name".inp" , " r " , stdin);freopen(name".out" , " w " , stdout);
#define faster    ios_base :: sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0) ;
#define pii pair < int , int >
#define fi first
#define se second
#define mii map< int , int>
#define reset(a,val) memset(a ,val , sizeof(a) )
#define count_bit(i) __builtin_popcountll(i) 
#define mask(i) ((1LL << (i)))  
#define status(x, i) (((x) >> (i)) & 1)  
#define set_on(x, i) ((x) | mask(i)) 
#define set_off(x, i) ((x) & ~mask(i))
#define endl '\n'    
#define ll long long
const int maxn = 1e6 + 6;
const int mod= 1e9 + 7;
const ll INFLL= 3e18 + 5;
const int INF = 1e9 + 5 ;
const int LOG = 20 ;


template <class T> inline T sqr(T x) { return x * x; };

template <class T> inline int Power(T x, int y) 

{ if (!y) return 1; if (y & 1) return sqr(Power(x, y / 2)) % mod * x % mod; return sqr(Power(x, y / 2)) % mod; }

template<class T> bool minimize(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool maximize(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

inline int gcd(int x, int y) 
{ return y ? gcd(y , x % y) : x;}

inline int lcm(int x, int y) { return x * y / gcd(x, y); }

using namespace std;

double calc(int ax , int ar , int bx)
{
    return (ax - bx) * (ax - bx) / (4.0 * ar);
}
int n;
stack<pair<int, double>> s;
double ans[maxn];
void solve()
{

    cin >> n ;

    for (int i = 1 ; i <= n ; ++i)
        {
            int x , r ; cin >> x >> r;
            double maxr = r;
            while (!s.empty())
                {
                    minimize(maxr , calc(s.top().fi , s.top().se , x));

                    if (maxr > s.top().se)
                        {
                            s.pop();
                        }
                    else break;

                }       
            
            s.push({x , maxr});
            ans[i] = maxr;
        }

    for (int i = 1 ; i <= n ; ++i) cout << setprecision(3) << fixed << ans[i] << endl;

}


int32_t main()
{
    faster;
    // file("txt");
    // int t ; cin >> t ; while (t--)
    solve();
    return 0;
} 
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 8th numbers differ - expected: '8.7410000000', found: '9.0910000000', error = '0.3500000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB 2nd numbers differ - expected: '252735385.4379999936', found: '0.9330000000', error = '252735384.5049999952'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 9 ms 1012 KB 44th numbers differ - expected: '165.0000000000', found: '165.0020000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 3924 KB 250th numbers differ - expected: '15134.0000000000', found: '-10429.6650000000', error = '25563.6650000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 5200 KB 286th numbers differ - expected: '7633.9990000000', found: '7634.0010000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 5744 KB 511th numbers differ - expected: '4494.0050000000', found: '4494.0070000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 6740 KB 165th numbers differ - expected: '1698.9980000000', found: '1699.0000000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 103 ms 7508 KB 249th numbers differ - expected: '2683.0090000000', found: '2683.0110000000', error = '0.0020000000'
2 Halted 0 ms 0 KB -