AtCoder abc281 E
// compile: g++ -o data data.cpp -O3 -std=gnu++20 -Wall -Wextra -Wshadow -D_GLIBCXX_ASSERTIONS -ggdb3 -fmax-errors=2 -DLOCAL
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) {_variables(#x);_print(x);}
#else
#define debug(x...)
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INTINF (int)(1152921504606846976)
#define int long long
#define MAXN 200010

int n, m, k, a[MAXN];
set<pair<int, int>> A, B;

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> n >> m >> k;
    rep(i, 0, n) cin >> a[i];
    vector<pair<int, int>> v;
    rep(i, 0, m) v.push_back({a[i], i});
    sort(v.begin(), v.end());
    int sum = 0;
    rep(i, 0, k) A.insert(v[i]), sum += v[i].first;
    rep(i, k, m) B.insert(v[i]);
    cout << sum;
    rep(i, 0, n-m) {
        pair<int, int> head = {a[i], i}, tail = {a[i+m], i+m};
        if (A.find(head) != A.end()) sum -= head.first, A.erase(A.find(head));
        else B.erase(B.find(head));
        if (tail < *(B.begin())) sum += tail.first, A.insert(tail);
        else B.insert(tail);
        if (sz(A) < k) sum += B.begin()->first, A.insert(*(B.begin())), B.erase(B.begin());
        if (sz(A) > k) sum -= A.rbegin()->first, B.insert(*(A.rbegin())), A.erase(--A.end());
        cout << " " << sum;
    }
    cout << endl;

    return 0;
}

Comments

  1. 10 months ago
    2025-12-06 2:38:07

    Hey there! Gave win99club a try the other day. Pretty decent selection of games, and the signup process was a breeze. If you’re looking for a new spot to hang out online, give it a shot!

  2. 9 months ago
    2025-12-19 13:52:59

    Hey, checked out wimi.com jogo on Winmiibet! Good selection of games, pretty smooth experience overall. Need to try it again soon! Check it out here: wimi.com jogo

  3. 9 months ago
    2025-12-29 6:21:07

    keobovn, huh? This one is kinda new to me. Giving it a try. It looks alright so far, let’s see if it hits the spot! Not ready to give a final verdict, but will check here again to share how the experience goes.

  4. 1 month ago
    2026-8-09 1:10:50

    I have been playing for years and vnzc88 is hands down one of the smoothest platforms I have ever used. Deposits process in no time and the game library keeps getting better with every update. I always come back because the vibe is so welcoming. Join the fun at vnzc88

  5. 1 month ago
    2026-8-09 1:11:09

    I was on the fence at first but this place really walks the talk. The welcome reward is straight forward and the playthrough conditions are actually fair compared to what the rest of the industry offers. I landed a solid hit last weekend and the payout landed in my wallet before I finished my morning coffee. It really feels like a game where luck and respect go hand in hand. vnea88

  6. 1 month ago
    2026-8-09 1:11:29

    What a fantastic place to spin the reels and chase those big wins. I joined a few months ago and the customer support is always ready to help with a smile. The promotions are generous and withdrawals are processed quicker than I expected. You really need to give this spot a try and see the excitement for yourself at ole777slot

  7. 3 weeks ago
    2026-8-30 7:00:24

    I’ve been playing here for a week now and the payouts are surprisingly fast. Really enjoying the game variety on phjiliglory!

  8. 1 week ago
    2026-9-07 19:14:51

    Been playing here for a week and the winning streaks are real. The atmosphere and the game mechanics are just spot on. Love ph33jili so much.

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
Previous
Next