제출 #1071314

#제출 시각아이디문제언어결과실행 시간메모리
1071314vjudge1Addk (eJOI21_addk)C++17
36 / 100
2032 ms4316 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define pb push_back #define sz size #define mp make_pair #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define fre(s) freopen(s".in", "r", stdin);freopen(s".out", "w", stdout); #define s second #define f first #define ii pair<ll,ll> const ll mod=1e9+7; const int N=4e5+6; const ll inf=1e12+5; ll n,k,d[N],g[N]; int main() { ios cin>>n>>k; for(int i=1;i<=n;++i) { cin>>d[i]; } int q; cin>>q; while(q--) { int x; cin>>x; if(x==1) { for(int i=0;i<k;++i) { cin>>g[i]; } if(k>1) { ll h=d[g[0]]; for(int i=0;i<k-1;i++) { d[g[i]]=d[g[i+1]]; } d[g[k-1]]=h; } } else { ll l,r,m; cin>>l>>r>>m; ll ans=0; if(r-l+1<m) { cout<<0<<"\n"; continue; } for(int i=l;i<=r;++i) { ll cur=m; cur-=max(0ll,m-(i-l+1)); cur-=max(0ll,m-(r-i+1)); ans+=d[i]*cur; } cout<<ans<<endl; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...