Submission #1008984

# Submission time Handle Problem Language Result Execution time Memory
1008984 2024-06-27T07:26:40 Z LilPluton Addk (eJOI21_addk) C++14
36 / 100
2000 ms 1868 KB
#include <bits/stdc++.h>
/// author: LilPluton auuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu
#define OPT ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define intt long long
#define arr array
#define vll vector<ll>
#define fi first
#define se second
#define rep(i,j,k) for(int i = j; i <= k; ++i)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define endll '\n'
using namespace std;

const intt N = 2e5 + 6;
const intt mod = 1e9 + 7;
int a[N], t[N * 4];

int n;
vector<ll> ft;
void init(int N)
{
    n = N + 5;
    ft.assign(n + 5, 0);
}
void add(ll pos, ll val)
{
    for (pos = pos + 1; pos <= n; pos += pos & -pos) ft[pos] += val;
}
ll get(ll pos, ll res = 0)
{
    for (pos = pos + 1; pos > 0; pos -= pos & -pos) res += ft[pos];
        return res;
}

signed main()
{
    OPT
    ll n, k;
    cin >> n >> k;
    init(n);

    for(ll i = 1; i <= n; ++i)
        cin >> a[i], add(i, a[i]);
    

    ll q;
    cin >> q;
    while(q--)
    {
        ll t;
        cin >> t;
        if(t == 1)
        {
            ll p;
            cin >> p;
        }
        else
        {
            ll l, r, m, ans = 0;
            cin >> l >> r >> m;
            for(ll i = l; i + m - 1 <= r; ++i)
            {
                ans += get(i + m - 1);
                ans -= get(i - 1);
            }
            cout << ans << endll;
        }
    }

}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
3 Correct 11 ms 508 KB Output is correct
4 Correct 25 ms 344 KB Output is correct
5 Correct 50 ms 348 KB Output is correct
6 Correct 70 ms 536 KB Output is correct
7 Correct 100 ms 564 KB Output is correct
8 Correct 148 ms 592 KB Output is correct
9 Correct 307 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1092 ms 972 KB Output is correct
2 Execution timed out 2059 ms 1868 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2100 ms 1108 KB Time limit exceeded
2 Halted 0 ms 0 KB -