結果
| 問題 |
No.3284 Picnic with Friends
|
| コンテスト | |
| ユーザー |
👑 testestest
|
| 提出日時 | 2025-09-26 21:42:10 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 6,824 ms / 7,000 ms |
| コード長 | 768 bytes |
| コンパイル時間 | 3,205 ms |
| コンパイル使用メモリ | 288,384 KB |
| 実行使用メモリ | 19,920 KB |
| 最終ジャッジ日時 | 2025-10-08 16:56:21 |
| 合計ジャッジ時間 | 82,624 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 |
ソースコード
#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';
}
}
testestest