Submission #553019

# Submission time Handle Problem Language Result Execution time Memory
553019 2022-04-24T12:54:08 Z Fidan Addk (eJOI21_addk) C++17
0 / 100
136 ms 3996 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf=(1e18);
const ll N=1'000'010;

ll n, k, i;
vector<ll> v;
vector<ll> sum;
vector<ll> pre;

ll prefix(ll l, ll r){
	ll s=0;
	s=pre[r]-pre[l-1]-(l-1)*(sum[r]-sum[l-1]);
	return s;
}

ll suffix(ll l, ll r){
	ll s=0;
	s=(r-l+2)*(sum[r]-sum[l-1])-prefix(l, r);
	return s;
}

void solve(ll l, ll r, ll m){
	ll s=0, k=r-l+1;
	if(2*m<=k){
		s=prefix(l, l+m-1)+m*(sum[r-m]-sum[l+m])+suffix(r-m+1, r);
	}
	else {
		s=prefix(l, l+k/2-1)+suffix(l+k/2, r);
	}
	cout<<s<<endl;
}

int main(){
	
	cin>>n>>k;
	v.push_back(0);
	pre.push_back(0);
	sum.push_back(0);
	
	for(i=1; i<=n; i++){
		ll a;
		cin>>a;
		v.push_back(a);
		pre.push_back(0);
		sum.push_back(0);
	}
	
	for(i=1; i<=n; i++){
		sum[i]=sum[i-1]+v[i];
		pre[i]=pre[i-1]+v[i]*i;
	}
	
	ll qu;
	cin>>qu;
	while(qu--){
		ll asdf;
		cin>>asdf;
		if(asdf==1){
			for(i=0; i<k; i++){
				ll asdf1;
				cin>>asdf1;
			}
		}
		else {
			ll l, r, m;
			cin>>l>>r>>m;
			solve(l, r, m);
		}
	}
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 54 ms 1588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 136 ms 3996 KB Output isn't correct
2 Halted 0 ms 0 KB -