結果
| 問題 | No.3614 Breaking door keys(LITTLE BREAK ver.) |
| コンテスト | |
| ユーザー |
umezo
|
| 提出日時 | 2026-08-09 20:07:30 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 630 ms / 2,000 ms |
| + 411µs | |
| コード長 | 1,799 bytes |
| 記録 | |
| コンパイル時間 | 2,886 ms |
| コンパイル使用メモリ | 349,032 KB |
| 実行使用メモリ | 51,200 KB |
| 最終ジャッジ日時 | 2026-08-09 20:07:47 |
| 合計ジャッジ時間 | 15,397 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_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 点 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n-1);i>=0;i--)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
template <class T> using V=vector<T>;
template <class T> using VV=V<V<T>>;
using u128=__int128_t;
using ll=long long;
const int INF=2e9+7;
template <typename X>
struct SegTree{
using FX=function<X(X,X)>;
int n;
FX fx;
const X ex;
vector<X> dat;
SegTree(int n_,FX fx_,X ex_) : n(),fx(fx_),ex(ex_),dat(n_*4,ex_){
int x=1;
while(n_>x) x*=2;
n=x;
}
void set(int i,X x){dat[i+n-1]=x;}
void build(){
for(int k=n-2;k>=0;k--) dat[k]=fx(dat[2*k+1],dat[2*k+2]);
}
void update(int i,X x){
i+=n-1;
dat[i]=x;
while(i>0){
i=(i-1)/2;
dat[i]=fx(dat[i*2+1],dat[i*2+2]);
}
}
X get(int i){return dat[i+n-1];}
X all(){return dat[0];}
X query(int a,int b){ return query_sub(a,b,0,0,n);}
X query_sub(int a,int b,int k,int l,int r){
if(r<=a || b<=l) return ex;
else if(a<=l && r<=b) return dat[k];
else{
X vl=query_sub(a,b,k*2+1,l,(l+r)/2);
X vr=query_sub(a,b,k*2+2,(l+r)/2,r);
return fx(vl,vr);
}
}
};
int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n,q;
cin>>n>>q;
V<ll> S(n);
rep(i,n) cin>>S[i];
using XX=V<ll>;
auto fx=[](XX x1,XX x2)->XX{
x1.append_range(x2);
sort(ALL(x1));
V<ll> B(10);
rep(i,10) B[i]=x1[i];
return B;
};
V<ll> B(10,INF);
XX ex=B;
SegTree<XX> seg(n,fx,ex);
rep(i,n){
V<ll> C(10,INF);
C[0]=S[i];
seg.set(i,C);
}
seg.build();
while(q--){
int l,r,k;
cin>>l>>r>>k;
l--;
auto a=seg.query(l,r);
cout<<accumulate(a.begin(),a.begin()+k,0ll)<<'\n';
}
return 0;
}
umezo