結果

問題 No.2359 A in S ?
ユーザー shobonvipshobonvip
提出日時 2023-06-23 21:53:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 674 ms / 2,000 ms
コード長 1,009 bytes
コンパイル時間 4,242 ms
コンパイル使用メモリ 260,412 KB
実行使用メモリ 102,472 KB
最終ジャッジ日時 2023-09-13 16:54:38
合計ジャッジ時間 14,983 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
101,812 KB
testcase_01 AC 88 ms
101,820 KB
testcase_02 AC 95 ms
101,944 KB
testcase_03 AC 89 ms
101,744 KB
testcase_04 AC 644 ms
102,396 KB
testcase_05 AC 674 ms
102,392 KB
testcase_06 AC 641 ms
102,396 KB
testcase_07 AC 304 ms
102,408 KB
testcase_08 AC 319 ms
102,352 KB
testcase_09 AC 286 ms
102,396 KB
testcase_10 AC 296 ms
102,288 KB
testcase_11 AC 304 ms
102,408 KB
testcase_12 AC 646 ms
102,348 KB
testcase_13 AC 644 ms
102,316 KB
testcase_14 AC 646 ms
102,412 KB
testcase_15 AC 283 ms
102,336 KB
testcase_16 AC 645 ms
102,316 KB
testcase_17 AC 646 ms
102,468 KB
testcase_18 AC 652 ms
102,396 KB
testcase_19 AC 648 ms
102,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

int main(){
	// if X[i] <= 100, then do for anytime.
	
	const int BORDER = 250;
	const int MX = 100005;

	int n, m; cin >> n >> m;
	vector<int> ans(m);
	vector<int> bucket(MX);
	vector<vector<int>> imos(BORDER, vector<int>(MX, 0));
	for (int i=0; i<n; i++){
		int l, r, x, y; cin >> l >> r >> x >> y;
		r++;
		int v = ((l - y + x - 1) / x) * x + y;
		assert (l <= v);
		if (x >= BORDER){
			while (v < r){
				if (l <= v) bucket[v]++;
				v += x;
			}
		}else{
			if (v < r){
				imos[x][v]++;
				imos[x][v + ((r - v + x - 1) / x) * x]--;
			}
		}
	}
	for (int i=1; i<BORDER; i++){
		for (int j=0; j<MX-i; j++){
			imos[i][j+i] += imos[i][j];
		}
	}
	vector<int> a(m);
	for (int i=0; i<m; i++){
		cin >> a[i];
		ans[i] += bucket[a[i]];
		for (int j=0; j<BORDER; j++){
			ans[i] += imos[j][a[i]];
		}
	}
	for (int i=0; i<m; i++){
		cout << ans[i] << "\n";
	}

}
 
0