結果

問題 No.633 バスの運賃
ユーザー tentententen
提出日時 2022-08-02 12:58:27
言語 Java21
(openjdk 21)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,186 bytes
コンパイル時間 2,224 ms
コンパイル使用メモリ 74,072 KB
実行使用メモリ 49,864 KB
最終ジャッジ日時 2023-09-30 12:13:38
合計ジャッジ時間 3,219 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,236 KB
testcase_01 AC 44 ms
49,204 KB
testcase_02 AC 43 ms
49,372 KB
testcase_03 AC 47 ms
49,864 KB
testcase_04 AC 47 ms
49,448 KB
testcase_05 AC 43 ms
49,372 KB
testcase_06 AC 43 ms
49,620 KB
testcase_07 AC 44 ms
49,368 KB
testcase_08 AC 43 ms
49,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        long[] sums = new long[n];
        for (int i = 1; i < n; i++) {
            sums[i] = sums[i - 1] + sc.nextInt();
        }
        long total = 0;
        for (int i = 0; i < n; i++) {
            total += sums[i] * (sc.nextInt() - sc.nextInt());
        }
        System.out.println(total);
    }
}

class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public double nextDouble() throws Exception {
        return Double.parseDouble(next());
    }
    
    public String next() throws Exception {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}
0