Submission #583724

# Submission time Handle Problem Language Result Execution time Memory
583724 2022-06-26T07:02:48 Z n3rm1n Addk (eJOI21_addk) C++17
0 / 100
5 ms 596 KB
#include<bits/stdc++.h>

using namespace std;
int n,k;
int a[10001];
int t[40001];
int p[10001];
void read()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        {cin>>a[i];p[i]=p[i-1]+a[i];}
}
void make_tree(int i,int l,int r)
{
    if(l>r)return;
    if(l==r)
    {
        t[i]=a[l];
        return;
    }
    int m=(l+r)/2;
    make_tree(i*2,l,m);
    make_tree(i*2+1,m+1,r);
    t[i]=t[i*2]+t[i*2+1];
}
int query(int i,int l,int r,int ql,int qr)
{
    if(l>r||r<ql||l>qr)return 0;
    if(l>=ql&&qr>=r)return t[i];
    int m=(l+r)/2;
    return query(i*2,l,m,ql,m)+query(i*2+1,m+1,r,m+1,qr);
}
void test()
{
    for(int i=1;i<=n*4;i++)
        cout<<t[i]<<" ";
    cout<<endl;
}
int q;
void solve()
{
    cin>>q;
    for(int i=1;i<=q;i++)
    {
        int c;
        cin>>c;
        if(c==1)
        {
            int help;
            cin>>help;
        }
        else
        {
            int ql,qr,m;
            cin>>ql>>qr>>m;
            int ans=0;
            for(int j=ql;j<=qr-m+1;j++)
            {
                ans+=p[j+m-1]-p[j-1];
                //ans+=query(1,1,n,j,j+m-1);
                //cout<<j<<" "<<j+m-1<<" "<<query(1,1,n,j,j+m-1)<<"||";
            }
            cout<<ans<<endl;
        }
    }
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	read();
	//make_tree(1,1,n);
	//test();
	solve();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Incorrect 5 ms 340 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 596 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 528 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -