結果

問題 No.2359 A in S ?
ユーザー erbowlerbowl
提出日時 2023-06-26 19:18:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,531 bytes
コンパイル時間 2,362 ms
コンパイル使用メモリ 208,956 KB
実行使用メモリ 261,992 KB
最終ジャッジ日時 2023-09-16 13:56:25
合計ジャッジ時間 26,479 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 710 ms
257,664 KB
testcase_01 AC 762 ms
257,752 KB
testcase_02 AC 770 ms
257,808 KB
testcase_03 AC 764 ms
257,804 KB
testcase_04 AC 963 ms
261,708 KB
testcase_05 AC 1,005 ms
261,748 KB
testcase_06 AC 998 ms
261,696 KB
testcase_07 AC 1,042 ms
261,556 KB
testcase_08 WA -
testcase_09 AC 1,048 ms
261,712 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 1,014 ms
261,728 KB
testcase_13 AC 1,064 ms
261,656 KB
testcase_14 AC 975 ms
261,648 KB
testcase_15 AC 1,010 ms
261,760 KB
testcase_16 AC 1,042 ms
261,788 KB
testcase_17 AC 970 ms
261,700 KB
testcase_18 AC 1,007 ms
261,680 KB
testcase_19 AC 1,022 ms
261,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,m;
    std::cin >> n>>m;
    vector<tuple<ll,ll,ll,ll>> q(n);
    for (int i = 0; i < n; i++) {
        ll l,r,x,y;
        std::cin >> l>>r>>x>>y;
        q[i] = {l,r,x,y};
    }
    vector<ll> a(m);
    for (int i = 0; i < m; i++) {
        std::cin >> a[i];
    }
    vector<ll> ans(100001);
    vector<vector<ll>> imos(100003,vector<ll>(320));
    for (int i = 0; i < n; i++) {
        auto [l,r,x,y] = q[i];
        
        if(x>=320){
            while(y<100000){
                if(l<=y&&y<=r){
                    ans[y]++;
                }
                y+= x;
            }
            continue;
        }
        
        ll st = max(0ll, (l-y+x-1)/x*x+y);
        ll en = min(100000ll, (r-y)/x*x+y);
        if(st<l)continue;
        if(r<st)continue;
        imos[st][x]++;
        if(en+x<=100000)imos[en+x][x]--;
    }
    // for (int j = 100; j <= 100; j++) {
    //     for (int i = 0; i <= 100; i++) {
    //         std::cout << imos[i][j]<<" ";
    //     }
    //     std::cout << std::endl;
    // }
    for (int i = 1; i < 320; i++) {
        for (int j = 1; j <= 100000; j++) {
            if(j-i>=0)imos[j][i] += imos[j-i][i];
        }
    }
    for (int j = 1; j <= 100000; j++) {
        for (int i = 1; i < 320; i++) {
            ans[j] += imos[j][i];
        }
    }
    for (int i = 0; i < m; i++) {
        std::cout << ans[a[i]] << std::endl;   
    }
}
0