結果
問題 | No.999 てん vs. ほむ |
ユーザー |
![]() |
提出日時 | 2021-09-09 23:05:38 |
言語 | C (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 472 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 29,312 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-12-31 13:02:22 |
合計ジャッジ時間 | 2,676 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 8 WA * 12 |
ソースコード
#include <stdio.h>#include <string.h>int main(void) {int i, n, l, r;int a[200000];long long ans;scanf("%d", &n);for (i = 0; i < 2 * n; ++i) scanf("%d", &a[i]);l = 0, r = 2 * n - 1;ans = 0;while (r - l >= 0) {if (a[l] - a[l+1] > a[r] - a[r-1]) {ans += a[l] - a[l+1];l += 2;} else {ans += a[r] - a[r-1];r -= 2;}}printf("%lld\n", ans);}