#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define repp(i,x,n) for(int i=x;i<=n;i++)
#define repo(i,x,n) for(int i=x;i>=n;i--)
#define cy cout<<"Yes"<<endl
#define cn cout<<"No"<<endl
#define r0 return 0
#define fi first
#define se second
#define mp make_pair
#define liow ios_base::sync_with_stdio(false);cin.tie(NULL)
#define jelek cout<<"jelek"<<endl
#define pii pair<int,int>
#define all(v) v.begin(),v.end()
#define pi pair<pair<int,int>,pair<int,int>>
#define p3 pair<pair<int,int>,int>
#define p4 pair<pii,pii>
#define fl fflush(stdout)
#define lb long double
using namespace std;
const int mod=1e9+7,maxn=1e6+5,N=(1<<17),INF=1e18;
void solve(){
int n,k;cin>>n>>k;
int arr[n+2];
repp(i,1,n) cin>>arr[i];
int q;cin>>q;
multiset<pii>in;
multiset<pii>out;
multiset<pii>st;
multiset<pii>stt;
multiset<pii>de;
multiset<pii>det;
while(q--){
int t;cin>>t;
int g;
if(t==1) repp(i,1,k) cin>>g;
else {
int l,r,m;cin>>l>>r>>m;
if(r>n) r=n;
if(m>r-l+1) m=r-l+1;
if(r-l+1==m || m==1){
st.insert(mp(l,1));
stt.insert(mp(r,1));
} else if(r-l==m || m==2){
in.insert(mp(l,1));
out.insert(mp(l,1));
st.insert(mp(l+1,2));
stt.insert(mp(r-1,2));
de.insert(mp(r,1));
det.insert(mp(r,1));
} else {
in.insert(make_pair(l,1));
out.insert(mp(l+m-2,m-1));
st.insert(mp(l+m-1,m));
stt.insert(mp(r-m+1,m));
de.insert(mp(r-m+2,m-1));
det.insert(mp(r,1));
}
}
}
int now=0;
int inc=0,dec=0,stay=0;
int ans=0;
repp(i,1,n){
if(!in.empty()){
while(!in.empty()){
pii cur=*in.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
in.erase(in.begin());
inc++;
now++;
}
}
if(!st.empty()){
while(!st.empty()){
pii cur=*st.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
st.erase(st.begin());
now+=val;
}
}
if(!de.empty()){
while(!de.empty()){
pii cur=*de.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
de.erase(de.begin());
dec++;
now+=val;
}
}
ans+=arr[i]*(now);
if(!out.empty()){
while(!out.empty()){
pii cur=*out.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
out.erase(out.begin());
inc--;
now-=val;
}
}
if(!stt.empty()){
while(!stt.empty()){
pii cur=*stt.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
stt.erase(stt.begin());
now-=val;
}
}
if(!det.empty()){
while(!det.empty()){
pii cur=*det.begin();
int idx=cur.fi;
int val=cur.se;
if(idx!=i) break;
det.erase(det.begin());
dec--;
now-=val;
}
}
now+=inc;
now-=dec;
}
cout<<ans;
}
signed main(){
liow;
int t=1;
// cin>>t;
while(t--){
solve();
}
}
Compilation message
Main.cpp: In function 'void solve()':
Main.cpp:71:13: warning: unused variable 'val' [-Wunused-variable]
71 | int val=cur.se;
| ^~~
Main.cpp:64:19: warning: unused variable 'stay' [-Wunused-variable]
64 | int inc=0,dec=0,stay=0;
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
35 ms |
8020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
72 ms |
15184 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |