結果
| 問題 |
No.704 ゴミ拾い Medium
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-10 00:27:53 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 583 bytes |
| コンパイル時間 | 1,395 ms |
| コンパイル使用メモリ | 158,576 KB |
| 実行使用メモリ | 7,040 KB |
| 最終ジャッジ日時 | 2024-11-18 10:06:29 |
| 合計ジャッジ時間 | 9,585 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 3 WA * 41 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n;
int a[300300];
int x[300300], y[300300];
int main() {
cin >> 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];
long long ans = abs(x[n - 1] - a[n - 1]) + 0ll + y[n - 1];
for (int i = n - 2; i >= 0; i--) {
long long d1 = abs(x[i] - a[i]) + 0ll + y[i];
long long d2 = abs(x[i] - x[i + 1]) + 0ll + abs(y[i] - y[i + 1]);
ans += min(d1, d2);
}
cout << ans << endl;
return 0;
}