답안 #1103505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103505 2024-10-21T04:56:13 Z tsengang Addk (eJOI21_addk) C++14
36 / 100
2000 ms 2824 KB
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb  push_back
#define ertunt return
using namespace std;
ll n,q,k;
struct segtree{
    int n;
    vector<ll>d;
    segtree(ll n){
        d.resize(4*n);
        build(1,1,n);
    }
    void build(ll v,ll l,ll r){
        if(l==r){
            d[v]=0;
            return;
        }
        ll m=(l+r)/2;
        build(v*2,l,m);
        build(v*2+1,m+1,r);
        d[v]=d[v*2]+d[v*2+1];
    }
    ll query(ll v,ll l,ll r,ll L,ll R){
        if(L>R||l>R||L>r) return 0;
        if(L<=l&&r<=R){
            return d[v];
        }
        ll m=(l+r)/2;
        return query(v*2,l,m,L,R)+query(v*2+1,m+1,r,L,R);
    }
    void update(ll v,ll l,ll r,ll pos,ll val){
        if(pos<l||r<pos) return;
        if(l==r){
            d[v]=val;
            return;
        }
        ll m=(l+r)/2;
        update(v*2,l,m,pos,val);
        update(v*2+1,m+1,r,pos,val);
        d[v]=d[v*2]+d[v*2+1];
    }
    void updater(ll node, ll L, ll R, ll l, ll r, ll val){
        if (L > R || L > r || R < l)
            return;
        if (L == R){
            d[node] /= val;
            return;
        }
        ll mid = (L + R) / 2;
        updater(node*2, L, mid, l, r, val);
        updater(node*2 + 1, mid + 1, R, l, r, val);
        d[node] = d[node*2] + d[node*2+1];
    }
    void update2(ll v,ll l,ll r,ll pos){
        if(pos<l||r<pos) return;
        if(l==r){
            d[v]/=k;
            return;
        }
        ll m=(l+r)>>1;
        update2(v*2,l,m,pos);
        update2(v*2+1,m+1,r,pos);
        d[v]=d[v*2]+d[v*2+1];
    }
};
int main() {
    ll n, k;
    cin >> n >> k;
    ll a[n+1];
    ll b[n+1];
    b[0] = 0;
    for(ll i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = b[i-1]+a[i];
    }
    ll q;
    cin >> q;
    while(q--){
        ll s;
        cin >> s;
        if(s==2){
            ll l,r,m;
            cin >> l >> r >> m;
            ll ans = 0;
            for(ll i = l - 1; i <= r-m; i++){
                ans+=b[i+m] - b[i];
            }
            cout << ans << '\n';
        }
        if(s == 1){
            cin >> s;
        }
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 3 ms 336 KB Output is correct
3 Correct 6 ms 336 KB Output is correct
4 Correct 9 ms 508 KB Output is correct
5 Correct 13 ms 336 KB Output is correct
6 Correct 17 ms 336 KB Output is correct
7 Correct 29 ms 592 KB Output is correct
8 Correct 33 ms 592 KB Output is correct
9 Correct 45 ms 652 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 139 ms 800 KB Output is correct
2 Correct 285 ms 1352 KB Output is correct
3 Correct 483 ms 1608 KB Output is correct
4 Correct 1904 ms 2496 KB Output is correct
5 Execution timed out 2064 ms 2824 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 187 ms 1104 KB Output isn't correct
2 Halted 0 ms 0 KB -