結果

問題 No.2010 Magical Floor
ユーザー tarattata1tarattata1
提出日時 2021-01-14 00:15:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 1,221 bytes
コンパイル時間 657 ms
コンパイル使用メモリ 81,188 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-20 10:20:48
合計ジャッジ時間 1,783 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 6 ms
4,376 KB
testcase_13 AC 10 ms
4,376 KB
testcase_14 AC 10 ms
4,380 KB
testcase_15 AC 8 ms
4,376 KB
testcase_16 AC 9 ms
4,376 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 8 ms
4,376 KB
testcase_19 AC 13 ms
4,380 KB
testcase_20 AC 12 ms
4,376 KB
testcase_21 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#define INF 2140000000
using namespace std;

void solve()
{
    int n, x;
    cin >> n >> x;
    vector<int> h(n), a(n);
    int i, j;
    int preh = 0;
    for (i = 0; i < n; i++) {
        int curh; cin >> curh; 
        h[i] = curh - preh; preh = curh;
    }
    for (i = 0; i < n; i++) {
        cin >> a[i];
    }
    double ans = (double)x * a[0];
    int mina = INF;
    for (i = 0; i < n; i++) {
        if (a[i] < mina) {
            double sumdist = 0;
            double sumtime = 0;
            for (j = 0; j < i; j++) {
                double sint = (double)a[i] / a[j];
                double cost = sqrt(1 - sint * sint);
                double dist = sint/cost * h[j];
                sumdist += dist;
                sumtime += (double)h[j] / cost * a[j] * 2;
            }
            if (sumdist * 2 < x) {
                ans = min(ans, sumtime + (x - sumdist * 2) * a[i]);
            }
        }
        mina = min(mina, a[i]);
    }
    cout << setprecision(10) << ans << endl;
    return;
}

int main()
{
    int T, t;
    cin >> T;
    for (t = 0; t < T; t++) {
        solve();
    }
    return 0;
}
0