結果
| 問題 | No.3614 Breaking door keys(LITTLE BREAK ver.) |
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2026-08-08 18:13:13 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 383 ms / 2,000 ms |
| + 521µs | |
| コード長 | 3,031 bytes |
| 記録 | |
| コンパイル時間 | 5,903 ms |
| コンパイル使用メモリ | 393,832 KB |
| 実行使用メモリ | 28,416 KB |
| 最終ジャッジ日時 | 2026-08-08 18:13:29 |
| 合計ジャッジ時間 | 14,768 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_1 |
(要ログイン)
| サブタスク | 配点 | 結果 |
|---|---|---|
| サンプル | 0 % | AC * 3 |
| 小課題1 | 10 % | AC * 7 |
| 小課題2 | 20 % | AC * 7 |
| 小課題3 | 30 % | AC * 7 |
| 小課題4 | 30 % | AC * 14 |
| 小課題5 | 10 % | AC * 38 |
| 合計 | 2.5 * 100% = 250 点 |
ソースコード
#ifndef ONLINE_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
#define pass (void)0
#define INF (1<<30)-1
#define INFLL (1LL<<60)-1
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define rep2(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define repr2(i, a, b) for (int i = (int)(b) - 1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define YesNo(cond) cout << ((cond) ? "Yes\n" : "No\n")
#define YESNO(cond) cout << ((cond) ? "YES\n" : "NO\n")
using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
template <typename T> void print(const T& value) { cout << value << "\n"; }
template <typename T> void print(const vector<T>& vec) { for (auto& v : vec) cout << v << " "; cout << "\n"; }
template <typename T> void input(vector<T>& vec) { for (auto& v : vec) cin >> v; };
template <typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using vm = vector<mint>;
struct MergeSortTree {
int n, num;
vector<vector<long long>> tree;
MergeSortTree(const vector<long long> &init_val) {
n = init_val.size();
num = 1;
while (num < n) num <<= 1;
tree.assign(num * 2, {});
// 葉に初期値
for (int i = 0; i < n; i++) {
tree[num + i].push_back(init_val[i]);
}
// 内部ノードのマージ
for (int i = num - 1; i > 0; i--) {
int L = 2 * i, R = 2 * i + 1;
tree[i].resize(tree[L].size() + tree[R].size());
merge(tree[L].begin(), tree[L].end(), tree[R].begin(), tree[R].end(), tree[i].begin());
}
}
vl query(int l, int r) {
vl ans;
l += num; r += num;
while (l < r) {
if (l & 1) {
rep (i, min(sz(tree[l]), 10)) {
ans.push_back(tree[l][i]);
}
l++;
}
if (r & 1) {
rep (i, min(sz(tree[r-1]), 10)) {
ans.push_back(tree[r-1][i]);
}
}
l >>= 1; r >>= 1;
}
return ans;
}
};
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(10);
ll N, Q;
cin >> N >> Q;
vl S(N);
input(S);
MergeSortTree seg(S);
while (Q--) {
ll L, R, K;
cin >> L >> R >> K;
L --; R --;
auto res = seg.query(L, R+1);
sort(all(res));
ll ans = 0;
rep (i, min((ll)sz(res), K)) {
ans += res[i];
}
print(ans);
}
}
detteiuu