結果

問題 No.2359 A in S ?
ユーザー FplusFplusFFplusFplusF
提出日時 2023-06-24 14:48:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 469 ms / 2,000 ms
コード長 1,183 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 203,464 KB
実行使用メモリ 499,820 KB
最終ジャッジ日時 2023-09-14 10:11:59
合計ジャッジ時間 11,137 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,084 KB
testcase_01 AC 6 ms
8,516 KB
testcase_02 AC 29 ms
36,588 KB
testcase_03 AC 8 ms
10,196 KB
testcase_04 AC 463 ms
498,788 KB
testcase_05 AC 468 ms
499,556 KB
testcase_06 AC 455 ms
499,616 KB
testcase_07 AC 469 ms
499,620 KB
testcase_08 AC 467 ms
499,568 KB
testcase_09 AC 452 ms
499,572 KB
testcase_10 AC 453 ms
499,620 KB
testcase_11 AC 463 ms
499,560 KB
testcase_12 AC 458 ms
499,668 KB
testcase_13 AC 461 ms
499,688 KB
testcase_14 AC 459 ms
499,684 KB
testcase_15 AC 456 ms
499,564 KB
testcase_16 AC 451 ms
499,820 KB
testcase_17 AC 457 ms
499,612 KB
testcase_18 AC 453 ms
499,572 KB
testcase_19 AC 455 ms
499,652 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(n);
    vector<ll> cnt(1e5+1,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