結果

問題 No.2359 A in S ?
ユーザー kotatsugame
提出日時 2023-06-23 21:46:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 770 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 69,700 KB
実行使用メモリ 259,560 KB
最終ジャッジ日時 2024-07-01 01:22:00
合計ジャッジ時間 5,396 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cassert>
using namespace std;
int N,M;
int cnt[1<<17];
const int LIM=500;
int imos[LIM][1<<17];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin>>N>>M;
	for(int i=0;i<N;i++)
	{
		int L,R,X,Y;
		cin>>L>>R>>X>>Y;
		R++;
		int low=L-Y;
		if(low<=0)low=Y;
		else low=(low+X-1)/X*X+Y;
		if(X>=LIM)
		{
			while(low<R)
			{
				cnt[low]++;
				low+=X;
			}
		}
		else
		{
			if(low<R)
			{
				imos[X][low]++;
				int d=R-low;
				d=(d+X-1)/X*X;
				if(low+d<1<<17)imos[X][low+d]--;
			}
		}
	}
	for(int x=1;x<LIM;x++)
	{
		for(int y=0;y+x<1<<17;y++)imos[x][y+x]+=imos[x][y];
		for(int y=0;y<1<<17;y++)cnt[y]+=imos[x][y];
	}
	for(int i=0;i<M;i++)
	{
		int a;cin>>a;
		cout<<cnt[a]<<"\n";
	}
}
0