結果

問題 No.633 バスの運賃
ユーザー vrjfsyivrjfsyi
提出日時 2018-05-22 08:48:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 826 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 71,600 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-11 01:11:17
合計ジャッジ時間 1,174 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <array>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <numeric>

using namespace std;


int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    int as[100];
    int a;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a;
        as[i] = a;
    }

    int b, c;
    int bs[100];
    int cs[100];

    for (int j = 0; j < n; ++j) {
        cin >> b >> c;
        bs[j] = b;
        cs[j] = c;
    }

    int m[101];
    m[0] = cs[0];
    for (int k = 1; k < n - 1; ++k) {
        m[k] = m[k - 1] - bs[k] + cs[k];
    }

    int result = 0;
    for (int l = 0; l < n - 1; ++l) {
        result += m[l] * as[l];
    }

    cout << result << "\n";

}
0