結果

問題 No.2359 A in S ?
ユーザー 沙耶花沙耶花
提出日時 2023-06-23 22:23:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 405 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 4,309 ms
コンパイル使用メモリ 259,316 KB
実行使用メモリ 5,736 KB
最終ジャッジ日時 2023-09-13 17:24:11
合計ジャッジ時間 11,686 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
4,376 KB
testcase_01 AC 66 ms
4,376 KB
testcase_02 AC 68 ms
4,380 KB
testcase_03 AC 69 ms
4,380 KB
testcase_04 AC 315 ms
5,456 KB
testcase_05 AC 341 ms
5,736 KB
testcase_06 AC 314 ms
5,412 KB
testcase_07 AC 345 ms
5,432 KB
testcase_08 AC 405 ms
5,600 KB
testcase_09 AC 308 ms
5,544 KB
testcase_10 AC 329 ms
5,584 KB
testcase_11 AC 342 ms
5,468 KB
testcase_12 AC 310 ms
5,436 KB
testcase_13 AC 316 ms
5,556 KB
testcase_14 AC 312 ms
5,408 KB
testcase_15 AC 307 ms
5,536 KB
testcase_16 AC 317 ms
5,472 KB
testcase_17 AC 318 ms
5,576 KB
testcase_18 AC 315 ms
5,512 KB
testcase_19 AC 315 ms
5,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

int main(){
	int B = 400;
	int N,M;
	cin>>N>>M;
	
	vector<int> l(N),rr(N),m(N),r(N);
	rep(i,N){
		cin>>l[i]>>rr[i]>>m[i]>>r[i];
	}
	
	
	vector<int> C(100005);
	rep(i,N){
		if(m[i]>=B){
			for(int j= r[i];j<C.size();j+=m[i]){
				if(j>=l[i]&&j<=rr[i])C[j]++;
			}
		}
	}
	
	for(int i=1;i<B;i++){
		vector<int> c(100005);
		rep(j,N){
			if(i==m[j]){
				rr[j]++;
				while((rr[j]-r[j])%i!=0)rr[j]++;
				
				while((l[j]-r[j])%i!=0)l[j]++;
				if(rr[j]<c.size())c[rr[j]]--;
				if(l[j]<c.size())c[l[j]]++;
			}
		}
		rep(j,c.size()){
			if(j+i<c.size())c[j+i] += c[j];
		}
		rep(j,c.size())C[j] += c[j];
	}
	
	rep(i,M){
		int a;
		cin>>a;
		cout<<C[a]<<endl;
	}
	
	return 0;
}
0