結果

問題 No.789 範囲の合計
ユーザー greentea011greentea011
提出日時 2019-03-19 13:45:03
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 619 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 84,432 KB
実行使用メモリ 271,704 KB
最終ジャッジ日時 2023-10-11 21:05:19
合計ジャッジ時間 6,096 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <map>
#include <functional>
#include <stdio.h>

struct hoge {
    long ans;
    int a;
    int b;
    std::map<int,int> imp;
    void calc(int q) {
        static std::map<int,std::function<void ()>> table = {
            {0, [this](){imp[a]+=b;}},
            {1, [this](){for (int i=a;i<=b;i++) ans+=imp[i];}},
        };
        table[q]();
    };
};

int main() {
    int q;
    int c;

    struct hoge Hoge;
    Hoge.ans = 0;

    scanf("%d",&c);
    for (int i=0;i<c;i++) {
        scanf("%d %d %d",&q,&(Hoge.a),&(Hoge.b));
        Hoge.calc(q);
    }
    printf("%ld\n",Hoge.ans);
}
0