結果

問題 No.633 バスの運賃
コンテスト
ユーザー WagiHOH
提出日時 2018-04-10 01:44:47
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
AC  
実行時間 1 ms / 2,000 ms
+ 102µs
コード長 574 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 304 ms
コンパイル使用メモリ 78,080 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2026-07-26 07:17:52
合計ジャッジ時間 1,278 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import std.algorithm;
import std.conv;
import std.stdio;
import std.string : chomp;

void main(string[] args)
{
    immutable n = readln.chomp.to!int;
    int[100] tariff, cumsum;
    foreach (i; 0..n - 1) {
        tariff[i + 1] = readln.chomp.to!int;
    }
    foreach (i; 1..n) {
        cumsum[i] = cumsum[i - 1] + tariff[i];
    }
    int total;
    foreach (i; 0..n) {
        int[2] passengers;
        readln.splitter.map!(to!int).copy(passengers[]);
        total += cumsum[i] * passengers[0];
        total -= cumsum[i] * passengers[1];
    }
    writeln(total);
}
0