답안 #1071686

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071686 2024-08-23T09:59:42 Z armashka Addk (eJOI21_addk) C++17
92 / 100
1565 ms 4944 KB
#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
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 348 KB Output is correct
4 Correct 4 ms 348 KB Output is correct
5 Correct 7 ms 600 KB Output is correct
6 Correct 11 ms 656 KB Output is correct
7 Correct 19 ms 604 KB Output is correct
8 Correct 23 ms 692 KB Output is correct
9 Correct 38 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 171 ms 2900 KB Output is correct
2 Correct 363 ms 3408 KB Output is correct
3 Correct 622 ms 3496 KB Output is correct
4 Correct 1160 ms 4176 KB Output is correct
5 Correct 1565 ms 4944 KB Output is correct
6 Correct 1461 ms 4756 KB Output is correct
7 Correct 1313 ms 4640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 331 ms 3412 KB Output isn't correct
2 Halted 0 ms 0 KB -