結果

問題 No.633 バスの運賃
ユーザー htensaihtensai
提出日時 2019-12-18 11:30:24
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 741 bytes
コンパイル時間 2,121 ms
コンパイル使用メモリ 72,896 KB
実行使用メモリ 49,512 KB
最終ジャッジ日時 2023-09-20 07:55:11
合計ジャッジ時間 3,365 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
49,472 KB
testcase_01 AC 45 ms
49,304 KB
testcase_02 AC 46 ms
49,252 KB
testcase_03 AC 47 ms
49,508 KB
testcase_04 AC 47 ms
49,512 KB
testcase_05 AC 44 ms
49,360 KB
testcase_06 AC 45 ms
49,284 KB
testcase_07 AC 46 ms
49,440 KB
testcase_08 AC 45 ms
49,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[] arr = new int[n];
        for (int i = 0; i < n - 1; i++) {
            arr[i] = Integer.parseInt(br.readLine());
        }
        int num = 0;
        long total = 0;
        for (int i = 0; i < n - 1; i++) {
            String[] line = br.readLine().split(" ", 2);
            int b = Integer.parseInt(line[0]);
            int c = Integer.parseInt(line[1]);
            num += c - b;
            total += num * arr[i];
        }
        System.out.println(total);
    }
}
0