結果
| 問題 |
No.3284 Picnic with Friends
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-26 22:12:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,064 bytes |
| コンパイル時間 | 3,984 ms |
| コンパイル使用メモリ | 257,832 KB |
| 実行使用メモリ | 23,576 KB |
| 最終ジャッジ日時 | 2025-09-26 22:12:32 |
| 合計ジャッジ時間 | 15,305 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 TLE * 1 -- * 19 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using isize = size_t;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
using f64 = long double;
using p2 = pair<i64, i64>;
using el = tuple<i64, i64, i64>;
using mint = atcoder::modint998244353;
void _main();
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(18);
_main();
}
i64 pow(i64 x, i64 n) {
i64 res = 1;
i64 t = x;
while (n > 0) {
if (n & 1) res *= t;
t *= t;
n >>= 1;
}
return res;
}
i64 pow(i64 x, i64 n, i64 m) {
i64 res = 1;
i64 t = x % m;
while (n > 0) {
if (n & 1) res = res * t % m;
t = t * t % m;
n >>= 1;
}
return res;
}
void _main() {
i64 n;
cin >> n;
vector<p2> s(n);
for (i64 i = 0; i < n; i++) {
cin >> s[i].first;
s[i].second = i;
}
sort(s.begin(), s.end());
i64 q;
cin >> q;
vector<i64> v;
i64 now = 0, sum = 0;
for (;q--;) {
i64 t, f;
cin >> t >> f;
if (now >= t) now += f, sum += f;
else {
v.push_back(sum);
now = t + f;
sum = f;
}
}
if (sum > 0) v.push_back(sum);
vector<i64> p(n + 1, 0);
for (i64 x : v) {
i64 b;
for (i64 i = 1; true; i++) {
if (x / i < i) {
b = x / i;
break;
}
i64 i1 = lower_bound(s.begin(), s.end(), (p2){i, 0}) - s.begin();
i64 i2 = lower_bound(s.begin(), s.end(), (p2){i + 1, 0}) - s.begin();
p[i1] += x / i;
p[i2] -= x / i;
}
for (i64 i = b; i >= 1; i--) {
i64 l = x / (i + 1) + 1, r = x / i + 1;
assert(x / l <= i);
assert(x / r < i);
i64 i1 = lower_bound(s.begin(), s.end(), (p2){l, 0}) - s.begin();
i64 i2 = lower_bound(s.begin(), s.end(), (p2){r, 0}) - s.begin();
p[i1] += i;
p[i2] -= i;
}
}
for (i64 i = 1; i <= n; i++) p[i] += p[i - 1];
vector<i64> ans(n);
for (i64 i = 0; i < n; i++) ans[s[i].second] = p[i];
for (i64 x : ans) cout << x << "\n";
}