結果
問題 |
No.633 バスの運賃
|
ユーザー |
|
提出日時 | 2018-03-04 13:03:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 1,457 bytes |
コンパイル時間 | 2,836 ms |
コンパイル使用メモリ | 77,184 KB |
実行使用メモリ | 50,476 KB |
最終ジャッジ日時 | 2024-07-07 05:55:31 |
合計ジャッジ時間 | 3,876 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 9 |
ソースコード
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()); } } }