제출 #1071678

#제출 시각아이디문제언어결과실행 시간메모리
1071678vjudge1Addk (eJOI21_addk)C++17
92 / 100
1519 ms6560 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define lld long double #define pb push_back #define pf push_front #define F first #define S second #define all(a) a.begin(),a.end() #define IShowSpeed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); const int N=1e5+10; const int K=405; const int mod=1e9+7; const ll inf=1e18+228; const int dx[]={-1,0,0,1}; const int dy[]={0,-1,1,0}; ll h[N],t[4*N]; void build(ll v, ll tl, ll tr) { if(tl==tr) { t[v]=h[tl]; return; } ll mid = (tl + tr) >> 1; build(v+v,tl,mid); build(v+v+1,mid+1,tr); t[v]=t[v+v]+t[v+v+1]; } ll get(ll v, ll tl, ll tr, ll l, ll r) { if(l<=tl && tr<=r) return t[v]; if(r<tl || tr<l) return 0; ll mid = (tl + tr) >> 1; return get(v+v,tl,mid,l,r)+get(v+v+1,mid+1,tr,l,r); } int main() { //freopen("closing.in","r",stdin); //freopen("closing.out","w",stdout); IShowSpeed ll tt=1; //cin>>tt; for(int cas=1;cas<=tt;cas++) { //for(int i=0;i<=K;i++) bl[i]={0,0}; //for(int i=1;i<=N-10;i++) h[i]=0; //cout<<"Case "<<cas<<":\n"; ll n,k,q; cin>>n>>k; for(int i=1;i<=n;i++) cin>>h[i]; build(1,1,n); cin>>q; while(q--) { ll tp; cin>>tp; if(tp==1) { vector<ll>v; for(int i=1;i<=k;i++) { ll x; cin>>x; v.pb(x); } } else { ll l,r,m,s; cin>>l>>r>>m; s=get(1,1,n,l,r)*m; for(int i=l,x=m-1;x>0;i++,x--) s-=h[i]*x; for(int i=r,x=m-1;x>0;i--,x--) s-=h[i]*x; cout<<s<<"\n"; } } } } /* 8 3 7 2 5 1 9 3 4 6 3 2 2 7 4 1 2 5 8 2 2 7 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...