結果
問題 | No.1012 荷物収集 |
ユーザー | kcvlex |
提出日時 | 2020-03-20 22:05:10 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 6,128 bytes |
コンパイル時間 | 2,148 ms |
コンパイル使用メモリ | 183,440 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-15 05:57:47 |
合計ジャッジ時間 | 5,835 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,820 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,820 KB |
testcase_04 | AC | 49 ms
10,368 KB |
testcase_05 | AC | 46 ms
10,496 KB |
testcase_06 | AC | 46 ms
10,496 KB |
testcase_07 | AC | 45 ms
10,496 KB |
testcase_08 | AC | 44 ms
10,368 KB |
testcase_09 | AC | 44 ms
10,496 KB |
testcase_10 | AC | 45 ms
10,496 KB |
testcase_11 | AC | 45 ms
10,624 KB |
testcase_12 | AC | 44 ms
10,496 KB |
testcase_13 | AC | 45 ms
10,496 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 2 ms
6,816 KB |
ソースコード
#include <bits/stdc++.h> #define ALL(v) std::begin(v), std::end(v) #define ALLR(v) std::rbegin(v), std::rend(v) using ll = std::int64_t; using ull = std::uint64_t; using pii = std::pair<int, int>; using tii = std::tuple<int, int, int>; using pll = std::pair<ll, ll>; using tll = std::tuple<ll, ll, ll>; template <typename T> using vec = std::vector<T>; template <typename T> using vvec = vec<vec<T>>; template <typename T> const T& var_min(const T &t) { return t; } template <typename T> const T& var_max(const T &t) { return t; } template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); } template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); } template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); } template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); } template <typename T> const T& clamp(const T &t, const T &low, const T &high) { return std::max(low, std::min(high, t)); } template <typename T> void chclamp(T &t, const T &low, const T &high) { return t = clamp(t, low, high); } template <typename T> T make_v(T init) { return init; } template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); } template <typename T, std::size_t Head, std::size_t ...Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; }; template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; }; template <typename T, std::size_t ...Args> using mdarray = typename multi_dem_array<T, Args...>::type; namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; } namespace tree { template <typename T> struct BIT { vec<T> data; T id_ele; BIT(ll size, T id_ele) : id_ele(id_ele) { ll bsize = 1; while (bsize < size) bsize *= 2; data = vec<T>(bsize + 1, id_ele); } T sum(ll pos) { T ret = id_ele; for (; 0 < pos; pos -= pos & -pos) ret += data[pos]; return ret; } T sum(ll l, ll r) { return sum(r) - sum(l); } void add(ll pos, T delta) { for (++pos; pos < data.size(); pos += pos & -pos) data[pos] += delta; } }; } namespace math { template <typename T> constexpr T pow(const T &n, ll k) { T ret = n.mul_id_ele(); T cur = n; while (k) { if (k & 1) ret *= cur; cur *= cur; k /= 2; } return ret; } } namespace math { template <ll Mod> struct Modint { constexpr Modint(ll x) : x((Mod + x % Mod) % Mod) { } constexpr Modint() : Modint(0) { } constexpr Modint<Mod> add_id_ele() const { return Modint<Mod>(0); } constexpr Modint<Mod> mul_id_ele() const { return Modint<Mod>(1); } constexpr ll& value() { return x; } constexpr ll value() const { return x; } constexpr Modint& operator +=(const Modint &oth) { x += oth.value(); if (Mod <= x) x -= Mod; return *this; } constexpr Modint& operator -=(const Modint &oth) { x += Mod - oth.value(); if (Mod <= x) x -= Mod; return *this; } constexpr Modint& operator *=(const Modint &oth) { x *= oth.value(); x %= Mod; return *this; } constexpr Modint& operator /=(const Modint &oth) { x *= oth.inv(); x %= Mod; return *this; } constexpr Modint operator +(const Modint &oth) const { return Modint(x) += oth; } constexpr Modint operator -(const Modint &oth) const { return Modint(x) -= oth; } constexpr Modint operator *(const Modint &oth) const { return Modint(x) *= oth; } constexpr Modint operator /(const Modint &oth) const { return Modint(x) /= oth; } constexpr Modint operator -() const { return Modint((x != 0) * (Mod - x)); } template <typename T> constexpr typename std::enable_if<std::is_integral<T>::value, const Modint&>::type operator =(T t) { (*this) = Modint(std::forward<T>(t)); return *this; } constexpr Modint inv() const { return ::math::pow(*this, Mod - 2); } constexpr ll mod() const { return Mod; } private: ll x; }; } int main() { ll n, q; std::cin >> n >> q; vec<pll> xw(n); vec<ll> xv(q); for (auto &&e : xw) { ll x, w; std::cin >> x >> w; e = pll(x, w); } for (ll &e : xv) std::cin >> e; std::sort(ALL(xw)); std::sort(ALL(xv)); vec<ll> ans1(q), ans2(q); std::queue<pll> qf, qb; for (ll i = 0; i < n; i++) { qf.push(xw[i]); qb.push(xw[n - 1 - i]); } { ll sum = 0 , pre = 0; for (ll i = 0; i < q; i++) { ll x = xv[i]; if (i) ans1[i] += ans1[i - 1]; ans1[i] += (x - pre) * sum; pre = x; while (qf.size()) { ll xf, w; std::tie(xf, w) = qf.front(); if (x < xf) break; qf.pop(); sum += w; ans1[i] += (x - xf) * w; } } } { ll sum = 0, pre = 0; for (ll i = q - 1; 0 <= i; i--) { ll x = xv[i]; if (i + 1 < q) ans2[i] += ans2[i + 1]; ans2[i] += (pre - x) * sum; pre = x; while (qb.size()) { ll xb, w; std::tie(xb, w) = qb.front(); if (xb < x) break; qb.pop(); sum += w; ans2[i] += (xb - x) * w; } } } for (ll i = 0; i < q; i++) std::cout << ans1[i] + ans2[i] << '\n'; return 0; }