結果

問題 No.633 バスの運賃
ユーザー 37zigen
提出日時 2020-02-17 22:03:34
言語 Java
(openjdk 23)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 611 bytes
コンパイル時間 2,186 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 54,256 KB
最終ジャッジ日時 2024-10-06 15:15:39
合計ジャッジ時間 4,619 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

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