結果

問題 No.3284 Picnic with Friends
ユーザー 👑 testestest
提出日時 2025-09-26 21:42:10
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 6,755 ms / 7,000 ms
コード長 768 bytes
コンパイル時間 2,810 ms
コンパイル使用メモリ 288,408 KB
実行使用メモリ 19,192 KB
最終ジャッジ日時 2025-09-26 21:43:44
合計ジャッジ時間 77,831 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r)for(int i=(l);i<(r);i++)
using ll=long long;

int main(){
	map<ll,ll>dp;

	int n;
	cin >> n;
	vector<int>a(n);
	for(auto&x:a)cin >> x;
	
	int q;
	cin >> q;
	ll start=0;
	ll len=0;
	vector<ll>seg;
	while(q--){
		ll a,b;
		cin >> a >> b;
		if(a<=start+len){
			len+=b;
		}else{
			if(len)seg.push_back(len);
			start=a;
			len=b;
		}
	}
	if(len)seg.push_back(len);
	
	
	
	for(auto N:seg){
		for(ll L=1,R;L<=N;L=R){
			ll q=N/L;
			R=N/q+1;
			dp[L]+=q;
			dp[R]-=q;
		}
	}
	
	vector<pair<ll,ll>>temp;
	ll crr=0;
	for(auto[k,v]:dp){
		crr+=v;
		temp.push_back({k,crr});
	}
	
	for(auto x:a){
		auto it=lower_bound(temp.begin(),temp.end(),make_pair((ll)x,(ll)1e18));
		cout << (prev(it)->second) << '\n';
	}
}
0