답안 #1116651

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1116651 2024-11-22T04:21:00 Z who Balloons (CEOI11_bal) C++17
0 / 100
105 ms 8264 KB
#include <bits/stdc++.h>

using namespace std;

#define task "balloons"
#define etr "\n"
#define ll long long
#define ld long double
#define pii pair<int,int>
#define pli pair<long long,int>
#define pll pair<long long, long long>
#define fi first
#define se second
#define bg begin
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define lwb lower_bound
#define upb upper_bound
#define range(x, l, r) x+l, x+1+r
#define all(x) (x).bg(), (x).end()
#define compact(x) x.resize(unique(all(x)) - (x).bg())
#define sq(x) ((x)*(x))

auto start = chrono::high_resolution_clock::now();

void start_timer()
{
    start = chrono::high_resolution_clock::now();
}

ld elapsed()
{
    auto current = chrono::high_resolution_clock::now();
    ld duration = chrono::duration_cast<chrono::nanoseconds>(current - start).count();
    return duration / 1e9;
}
void freop()
{
	freopen(task".inp", "r", stdin);
	freopen(task".out", "w", stdout);
}

template<class U, class V> istream& operator >> (istream& in, pair<U, V>& p)
{
	in >> p.fi >> p.se;
	return in;
}

template<class U, class V> ostream& operator << (ostream& out, pair<U, V> p)
{
	out << "{" << p.fi << ' ' << p.se << "}";
	return out;
}

template<class T> ostream& operator << (ostream& out, vector<T>& v)
{
    out << "{";
	for (int i=0; i<v.size(); i++)
    {
        out << v[i];
        if (i != v.size() - 1) out << ", ";
    }

    out << "}";
	return out;
}
const int N=2e5, M=1e5, mod=1e9+7;

int n;
ll x[N+5], r[N+5];
long double ans[N+5];

ld calc(int i, int j)
{
    return sq(x[i] - x[j]) / (4 * ans[j]);
}

void process()
{
    cin >> n;
    for (int i=1; i<=n; i++) cin >> x[i] >> r[i];

    vector<int> st;
    st.reserve(n);

    for (int i=1; i<=n; i++)
    {
        while (!st.empty() && r[i] >= ans[st.back()]) st.pob();

        if (st.empty()) ans[i] = r[i];
        else ans[i] = min(r[i] * 1.0L, calc(i, st.back()));

        st.pb(i);

        cout << setprecision(3) << fixed << ans[i] << etr;
    }

}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	//freop();

	int t=1; //cin >> t;
	while (t--) process();

	return 0;
}

Compilation message

bal.cpp: In function 'void freop()':
bal.cpp:41:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |  freopen(task".inp", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bal.cpp:42:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   42 |  freopen(task".out", "w", stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB 4th numbers differ - expected: '1.8420000000', found: '87.0000000000', error = '85.1580000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB 2nd numbers differ - expected: '252735385.4379999936', found: '1000000000.0000000000', error = '747264614.5620000362'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB 6th numbers differ - expected: '213.0000000000', found: '238.0000000000', error = '25.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2384 KB 2nd numbers differ - expected: '122.0020000000', found: '123.0000000000', error = '0.9980000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 4972 KB 2nd numbers differ - expected: '212.0010000000', found: '213.0000000000', error = '0.9990000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 25 ms 5448 KB 2nd numbers differ - expected: '15398.0000000000', found: '24984.0000000000', error = '9586.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 6224 KB 2nd numbers differ - expected: '7937.0000000000', found: '10352.0000000000', error = '2415.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 6472 KB 2nd numbers differ - expected: '5059.0000000000', found: '5060.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 82 ms 7360 KB 2nd numbers differ - expected: '1873.0000000000', found: '1874.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 105 ms 8264 KB 2nd numbers differ - expected: '2961.0000000000', found: '2962.0000000000', error = '1.0000000000'
2 Halted 0 ms 0 KB -