結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 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 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 474 ms
12,192 KB
testcase_25 WA -
testcase_26 AC 450 ms
12,624 KB
testcase_27 AC 443 ms
12,548 KB
testcase_28 WA -
testcase_29 AC 465 ms
12,296 KB
testcase_30 AC 442 ms
12,384 KB
testcase_31 AC 439 ms
12,564 KB
testcase_32 AC 446 ms
12,648 KB
testcase_33 AC 442 ms
12,436 KB
testcase_34 AC 200 ms
12,472 KB
testcase_35 AC 200 ms
12,296 KB
testcase_36 AC 201 ms
12,404 KB
testcase_37 AC 200 ms
12,196 KB
testcase_38 AC 200 ms
12,248 KB
testcase_39 AC 201 ms
12,292 KB
testcase_40 AC 201 ms
12,548 KB
testcase_41 AC 201 ms
12,752 KB
testcase_42 AC 201 ms
12,244 KB
testcase_43 AC 200 ms
12,200 KB
testcase_44 AC 2 ms
4,376 KB
testcase_45 AC 1 ms
4,376 KB
testcase_46 AC 266 ms
12,396 KB
testcase_47 AC 255 ms
12,248 KB
testcase_48 AC 3 ms
4,380 KB
testcase_49 AC 3 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

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 (v[i] < m) {
        m = v[i];
        mi = i;
      }
    }
    if (look == 0) break;
    look = mi-1;
  }
  cout << v[0] << endl;
  return 0;
}
0