結果

問題 No.2359 A in S ?
ユーザー 遭難者遭難者
提出日時 2023-05-23 13:16:54
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 1,219 bytes
コンパイル時間 4,108 ms
コンパイル使用メモリ 251,168 KB
最終ジャッジ日時 2025-02-13 04:14:06
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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