結果

問題 No.2359 A in S ?
ユーザー 遭難者遭難者
提出日時 2023-05-23 13:16:54
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 1,219 bytes
コンパイル時間 4,187 ms
コンパイル使用メモリ 260,496 KB
実行使用メモリ 127,176 KB
最終ジャッジ日時 2023-08-29 05:25:41
合計ジャッジ時間 7,803 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
126,916 KB
testcase_01 AC 65 ms
126,900 KB
testcase_02 AC 65 ms
126,932 KB
testcase_03 AC 65 ms
126,928 KB
testcase_04 AC 104 ms
126,872 KB
testcase_05 AC 115 ms
126,924 KB
testcase_06 AC 105 ms
126,908 KB
testcase_07 AC 112 ms
126,924 KB
testcase_08 AC 119 ms
126,860 KB
testcase_09 AC 103 ms
126,996 KB
testcase_10 AC 109 ms
126,904 KB
testcase_11 AC 112 ms
127,000 KB
testcase_12 AC 104 ms
126,872 KB
testcase_13 AC 105 ms
126,868 KB
testcase_14 AC 105 ms
126,976 KB
testcase_15 AC 103 ms
126,996 KB
testcase_16 AC 105 ms
126,924 KB
testcase_17 AC 104 ms
127,176 KB
testcase_18 AC 104 ms
126,872 KB
testcase_19 AC 106 ms
126,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define ll int
#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define vc vector
using namespace std;
constexpr int inf = 1e5 + 1, s_inf = 316;
int pl[s_inf][inf], a[inf];
void solve()
{
    int n, m;
    cin >> n >> m;
    rep(k, n)
    {
        int l, r, x, y;
        cin >> l >> r >> x >> y;
        l = (l - y + x - 1) / x * x + y;
        r = (r - y + x) / x * x + y;
        if (x < s_inf)
        {
            pl[x][l]++;
            if (r < inf)
                pl[x][r]--;
        }
        else
        {
            while (l < r)
            {
                a[l]++;
                l += x;
            }
        }
    }
    for (int x = 1; x < s_inf; x++)
    {
        for (int y = x; y < inf; y++)
            pl[x][y] += pl[x][y - x];
        for (int y = 0; y < inf; y++)
            a[y] += pl[x][y];
    }
    for (int i = 0, x; i < m; i++)
    {
        cin >> x;
        cout << a[x] << '\n';
    }
}
int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(13);
    solve();
    return 0;
}
0