結果

問題 No.633 バスの運賃
ユーザー tetsutetsu
提出日時 2018-03-04 13:03:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 3,377 ms
コンパイル使用メモリ 75,208 KB
実行使用メモリ 49,876 KB
最終ジャッジ日時 2023-09-21 12:01:51
合計ジャッジ時間 4,583 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
49,440 KB
testcase_01 AC 48 ms
49,608 KB
testcase_02 AC 45 ms
49,304 KB
testcase_03 AC 45 ms
49,184 KB
testcase_04 AC 48 ms
49,124 KB
testcase_05 AC 43 ms
49,876 KB
testcase_06 AC 43 ms
49,136 KB
testcase_07 AC 45 ms
49,240 KB
testcase_08 AC 46 ms
49,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class P633 {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n-1];
		for(int i=0; i<n-1; i++) {
			a[i] = sc.nextInt();
		}
		int[] d = new int[n-1];
		int b = sc.nextInt();
		int c = sc.nextInt();
		d[0] = c;
		for(int i=1; i<n-1; i++) {
			int b1 = sc.nextInt();
			int c1 = sc.nextInt();
			d[i] = d[i-1]+c1-b1;
		}
		int ans = 0;
		for(int i=0; i<n-1; i++) {
			ans += d[i]*a[i];
		}
		System.out.println(ans);
	}

	static class MyScanner
	{
		BufferedReader br;
		StringTokenizer st;
		public MyScanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}
}
0