結果

問題 No.633 バスの運賃
コンテスト
ユーザー tetsu
提出日時 2018-03-04 13:03:48
言語 Java
(openjdk 26.0.2.1 + ACL)
コンパイル:
javac -J-Duser.language=en -encoding UTF8 -cp /opt/aclib/ac_library.jar _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true -cp .:/opt/aclib/ac_library.jar _class_
結果
AC  
実行時間 31 ms / 2,000 ms
+ 417µs
コード長 1,457 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,377 ms
コンパイル使用メモリ 84,544 KB
実行使用メモリ 40,548 KB
最終ジャッジ日時 2026-08-10 20:24:36
合計ジャッジ時間 4,173 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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