結果

問題 No.2359 A in S ?
ユーザー FplusFplusFFplusFplusF
提出日時 2023-06-24 14:49:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 471 ms / 2,000 ms
コード長 1,185 bytes
コンパイル時間 2,021 ms
コンパイル使用メモリ 202,996 KB
実行使用メモリ 499,728 KB
最終ジャッジ日時 2023-09-14 10:15:12
合計ジャッジ時間 13,025 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 411 ms
499,548 KB
testcase_01 AC 414 ms
499,544 KB
testcase_02 AC 416 ms
499,704 KB
testcase_03 AC 410 ms
499,524 KB
testcase_04 AC 452 ms
499,568 KB
testcase_05 AC 468 ms
499,708 KB
testcase_06 AC 453 ms
499,724 KB
testcase_07 AC 464 ms
499,728 KB
testcase_08 AC 471 ms
499,664 KB
testcase_09 AC 450 ms
499,556 KB
testcase_10 AC 460 ms
499,552 KB
testcase_11 AC 464 ms
499,556 KB
testcase_12 AC 456 ms
499,692 KB
testcase_13 AC 459 ms
499,708 KB
testcase_14 AC 451 ms
499,608 KB
testcase_15 AC 453 ms
499,684 KB
testcase_16 AC 450 ms
499,628 KB
testcase_17 AC 451 ms
499,556 KB
testcase_18 AC 453 ms
499,548 KB
testcase_19 AC 451 ms
499,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for (ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n,m;
    cin >> n >> m;
    ll t=sqrtl(1e5+1);
    vector<ll> cnt(1e5,0);
    vector<vector<ll>> imos(t,vector<ll>(2e5+1,0));
    while(n--){
        ll l,r,x,y;
        cin >> l >> r >> x >> y;
        ll a=(l/x)*x+y;
        if(a<l) a+=x;
        ll b=(r/x)*x+y;
        if(r<b) b-=x;
        if(b<l||r<a||b<a) continue;
        if(x<t){
            imos[x][a]++;
            imos[x][b+x]--;            
        }else{
            for(ll i=a;i<=b;i+=x) cnt[i]++;
        }
    }
    for(ll i=1;i<t;i++){
        for(ll j=1;j<=1e5;j++){
            cnt[j]+=imos[i][j];
            if(j+i<=1e5) imos[i][j+i]+=imos[i][j];
        }
    }
    while(m--){
        ll a;
        cin >> a;
        cout << cnt[a] << '\n';
    }
}
0