結果
問題 |
No.703 ゴミ拾い Easy
|
ユーザー |
![]() |
提出日時 | 2018-06-16 00:16:19 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 742 bytes |
コンパイル時間 | 1,599 ms |
コンパイル使用メモリ | 170,636 KB |
実行使用メモリ | 19,420 KB |
最終ジャッジ日時 | 2024-06-30 15:43:19 |
合計ジャッジ時間 | 5,854 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 TLE * 1 -- * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(){ cin.tie(0); ios::sync_with_stdio(false); 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 (look == 0) break; look--; } cout << v[0] << endl; return 0; }