結果

問題 No.633 バスの運賃
ユーザー 37zigen37zigen
提出日時 2020-02-17 22:03:34
言語 Java21
(openjdk 21)
結果
AC  
実行時間 164 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 2,869 ms
コンパイル使用メモリ 75,684 KB
実行使用メモリ 54,304 KB
最終ジャッジ日時 2024-04-16 03:59:14
合計ジャッジ時間 4,205 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
54,180 KB
testcase_01 AC 134 ms
54,304 KB
testcase_02 AC 139 ms
53,852 KB
testcase_03 AC 144 ms
53,916 KB
testcase_04 AC 164 ms
54,256 KB
testcase_05 AC 131 ms
54,128 KB
testcase_06 AC 135 ms
54,020 KB
testcase_07 AC 139 ms
54,188 KB
testcase_08 AC 139 ms
54,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] a=new int[n-1];
		int[] b=new int[n];
		int[] c=new int[n];
		int ans=0;
		int num=0;
		for(int i=0;i<n-1;++i)a[i]=sc.nextInt();
		for(int i=0;i<n;++i) {
			b[i]=sc.nextInt();
			c[i]=sc.nextInt();
			num+=c[i]-b[i];
			if(num>0)
				ans+=num*a[i];
		}
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0