// 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;
}
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!
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
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.
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
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
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
I’ve been playing here for a week now and the payouts are surprisingly fast. Really enjoying the game variety on phjiliglory!
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.