結果

問題 No.2359 A in S ?
ユーザー tsugutsugutsugutsugu
提出日時 2023-06-24 01:24:09
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 1,307 bytes
コンパイル時間 2,726 ms
コンパイル使用メモリ 248,560 KB
実行使用メモリ 137,372 KB
最終ジャッジ日時 2023-09-13 20:36:06
合計ジャッジ時間 8,163 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 144 ms
136,664 KB
testcase_01 AC 143 ms
136,644 KB
testcase_02 AC 145 ms
136,656 KB
testcase_03 AC 145 ms
136,716 KB
testcase_04 AC 183 ms
137,368 KB
testcase_05 AC 193 ms
137,328 KB
testcase_06 AC 185 ms
136,984 KB
testcase_07 AC 191 ms
137,044 KB
testcase_08 AC 194 ms
137,036 KB
testcase_09 AC 181 ms
137,244 KB
testcase_10 AC 184 ms
137,364 KB
testcase_11 AC 186 ms
137,372 KB
testcase_12 AC 182 ms
136,984 KB
testcase_13 AC 184 ms
137,252 KB
testcase_14 AC 182 ms
136,984 KB
testcase_15 AC 181 ms
137,280 KB
testcase_16 AC 183 ms
137,312 KB
testcase_17 AC 182 ms
136,996 KB
testcase_18 AC 182 ms
137,240 KB
testcase_19 AC 186 ms
137,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include "debug.hpp"
#else
#define debug(...) 1
#endif

const int MAX = 100000 + 5;
const int B = 340;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    vector<vector<int>> A(B, vector<int>(MAX, 0));
    vector<int> cnt(MAX, 0);
    vector<int> C(m);
    for (int i = 0; i < n; i++) {
        int L, R, X, Y;
        cin >> L >> R >> X >> Y;
        int vl = L / X * X + Y;
        while (vl < L) vl += X;
        while (vl - X >= L) vl -= X;
        int vr = R / X * X + Y;
        while (vr > R) vr -= X;
        while (vr + X <= R) vr += X;
        if (X < B) {
            A[X][vl]++;
            if (vr + X <= MAX) {
                A[X][vr + X]--;
            }
        } else {
            for (int j = vl; j <= vr; j += X) {
                cnt[j]++;
            }
        }
    }

    for (int i = 0; i < m; i++) {
        cin >> C[i];
    }

    for (int i = 1; i < B; i++) {
        for (int j = 0; j < MAX; j++) {
            if (j + i < MAX) {
                A[i][j + i] += A[i][j];
            }
        }
        for (int j = 0; j < MAX; j++) {
            cnt[j] += A[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        cout << cnt[C[i]] << '\n';
    }
    
}
0