結果

問題 No.151 セグメントフィッシング
ユーザー mayoko_mayoko_
提出日時 2015-02-12 23:45:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,222 ms / 5,000 ms
コード長 1,202 bytes
コンパイル時間 1,846 ms
コンパイル使用メモリ 72,780 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-06 00:17:01
合計ジャッジ時間 14,813 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 77 ms
4,376 KB
testcase_09 AC 77 ms
4,376 KB
testcase_10 AC 77 ms
4,376 KB
testcase_11 AC 77 ms
4,376 KB
testcase_12 AC 1,147 ms
4,376 KB
testcase_13 AC 1,147 ms
4,380 KB
testcase_14 AC 1,149 ms
4,376 KB
testcase_15 AC 1,146 ms
4,380 KB
testcase_16 AC 1,145 ms
4,376 KB
testcase_17 AC 1,104 ms
4,376 KB
testcase_18 AC 1,104 ms
4,380 KB
testcase_19 AC 1,222 ms
4,376 KB
testcase_20 AC 1,217 ms
4,380 KB
testcase_21 AC 1,092 ms
4,380 KB
testcase_22 AC 1,105 ms
4,380 KB
testcase_23 AC 28 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>

using namespace std;
typedef long long ll;

const int MAXN = 20020;
ll state[2][MAXN];
ll Next[2][MAXN];

int main(void) {
    int N, Q;
    cin >> N >> Q;
    while (Q--) {
        char x;
        int y, z;
        cin >> x;
        cin >> y >> z;
        if (x == 'R') {
            state[1][y] += z;
        } else if (x == 'L') {
            state[0][y] += z;
        } else {
            ll sum = 0;
            for (int i = y; i < z; i++) {
                sum += state[0][i] + state[1][i];
            }
            cout << sum << endl;
        }
        for (int i = 1; i < N; i++) {
            Next[1][i] = state[1][i-1];
        }
        Next[1][0] = state[0][0];
        for (int i = 0; i < N-1; i++) {
            Next[0][i] = state[0][i+1];
        }
        Next[0][N-1] = state[1][N-1];
        for (int i = 0; i < N; i++) {
            state[0][i] = Next[0][i];
            state[1][i] = Next[1][i];
        }
    }
    return 0;
}
0