結果

問題 No.703 ゴミ拾い Easy
ユーザー sugdxsugdx
提出日時 2018-06-15 23:53:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 767 bytes
コンパイル時間 1,547 ms
コンパイル使用メモリ 168,236 KB
実行使用メモリ 17,160 KB
最終ジャッジ日時 2023-09-13 05:29:37
合計ジャッジ時間 10,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,756 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 3 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 468 ms
12,468 KB
testcase_25 WA -
testcase_26 AC 448 ms
12,340 KB
testcase_27 AC 440 ms
12,720 KB
testcase_28 WA -
testcase_29 AC 463 ms
12,516 KB
testcase_30 AC 442 ms
12,300 KB
testcase_31 AC 437 ms
12,248 KB
testcase_32 AC 447 ms
12,620 KB
testcase_33 AC 434 ms
12,464 KB
testcase_34 TLE -
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>
using namespace std;

int main(){
  int n; cin >> n;
  vector<long long> a(n), x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> y[i];
  }
  int look = n-1; long long ans = 0;
  vector<long long> v(n+1, -1); v[n] = 0;
  while(look >= 0) {
    long long mi = -1; long long m = 1e18;
    for (int i = 0; i <= look; i++) {
      long long f = (a[look] - x[i]) * (a[look] - x[i]) + y[i]*y[i];
      if (v[i] > f + v[look+1] || v[i] == -1) {
        v[i] = f + v[look+1];
      }
      if (m >= v[i]) {
        m = v[i];
        mi = i;
      }
    }
    if (look == 0) break;
    look = mi-1;
  }
  cout << v[0] << endl;
  return 0;
}
0