結果

問題 No.705 ゴミ拾い Hard
コンテスト
ユーザー zelda_master
提出日時 2026-08-25 00:55:35
言語 C++14
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 915 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 372 ms
コンパイル使用メモリ 80,512 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2026-08-25 00:55:39
合計ジャッジ時間 3,202 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26 WA * 13 RE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010;
const LL INF = 9e18;

PII p[N];
int n, a[N];
LL f[N][N], mi[N];

LL Calc(int hum, int gar) {
    int dx = abs(a[hum] - p[gar].first); 
    int dy = abs(0 - p[gar].second);
    return 1LL * dx * dx * dx + 1LL * dy * dy * dy;
}

int main() {
    // freopen("gabbage.in", "r", stdin);
    // freopen("gabbage.out", "w", stdout);

    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    for (int i = 1; i <= n; ++i) scanf("%d", &p[i].first);
    for (int i = 1; i <= n; ++i) scanf("%d", &p[i].second);

    for (int i = 1; i <= n; ++i) {
        mi[i] = INF;
        for (int j = 1; j <= i; ++j) {
            f[i][j] = mi[j - 1] + Calc(i, j);
            mi[i] = min(mi[i], f[i][j]);
        }
    }

    printf("%lld\n", mi[n]);

    return 0;
}
0