結果

問題 No.929 よくあるボールを移動するやつ
ユーザー htensaihtensai
提出日時 2019-12-09 21:50:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 409 bytes
コンパイル時間 4,360 ms
コンパイル使用メモリ 72,124 KB
実行使用メモリ 60,756 KB
最終ジャッジ日時 2023-09-05 10:52:43
合計ジャッジ時間 9,157 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,892 KB
testcase_01 AC 123 ms
55,712 KB
testcase_02 AC 122 ms
55,752 KB
testcase_03 AC 126 ms
55,772 KB
testcase_04 AC 123 ms
55,532 KB
testcase_05 AC 128 ms
55,704 KB
testcase_06 AC 137 ms
55,768 KB
testcase_07 AC 341 ms
60,160 KB
testcase_08 AC 454 ms
60,756 KB
testcase_09 AC 457 ms
60,740 KB
testcase_10 AC 458 ms
60,552 KB
testcase_11 AC 456 ms
60,704 KB
testcase_12 AC 450 ms
60,540 KB
testcase_13 AC 451 ms
60,228 KB
testcase_14 AC 442 ms
60,432 KB
testcase_15 AC 458 ms
60,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int remein = 0;
        long count = 0;
        for (int i = 0; i < n; i++) {
            int x = sc.nextInt() + remein;
            remein = x - 1;
            count += Math.abs(remein);
        }
        System.out.println(count);
    }
}
0