結果

問題 No.703 ゴミ拾い Easy
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2018-06-15 23:04:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,851 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 164,584 KB
実行使用メモリ 17,164 KB
最終ジャッジ日時 2023-09-13 05:09:55
合計ジャッジ時間 8,431 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,508 KB
testcase_01 AC 2 ms
9,520 KB
testcase_02 AC 3 ms
9,508 KB
testcase_03 AC 3 ms
9,688 KB
testcase_04 AC 2 ms
9,640 KB
testcase_05 AC 3 ms
9,524 KB
testcase_06 AC 3 ms
9,512 KB
testcase_07 AC 2 ms
9,560 KB
testcase_08 AC 2 ms
9,520 KB
testcase_09 AC 3 ms
9,524 KB
testcase_10 AC 3 ms
9,624 KB
testcase_11 AC 2 ms
9,616 KB
testcase_12 AC 2 ms
9,552 KB
testcase_13 AC 2 ms
9,508 KB
testcase_14 AC 4 ms
9,632 KB
testcase_15 AC 4 ms
9,520 KB
testcase_16 AC 3 ms
9,536 KB
testcase_17 AC 3 ms
9,528 KB
testcase_18 AC 4 ms
9,628 KB
testcase_19 AC 4 ms
9,524 KB
testcase_20 AC 4 ms
9,528 KB
testcase_21 AC 3 ms
9,528 KB
testcase_22 AC 3 ms
9,704 KB
testcase_23 AC 4 ms
9,528 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/






int N;
ll A[301010], X[301010], Y[301010];
ll dp[301010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 1, N + 1) cin >> A[i];
    rep(i, 1, N + 1) cin >> X[i];
    rep(i, 1, N + 1) cin >> Y[i];

    rep(i, 0, N + 1) dp[i] = infl;
    dp[0] = 0;
    
    rep(i, 1, N + 1) {
        ll mi = infl;
        rep(j, 0, i) {
            ll dx = A[i] - X[j + 1];
            ll dy = Y[j + 1];

            ll cst = dp[j] + dx * dx + dy * dy;
            chmin(mi, cst);
        }
        dp[i] = mi;
    }

    cout << dp[N] << endl;
}
0