Submission #1024244

# Submission time Handle Problem Language Result Execution time Memory
1024244 2024-07-15T18:42:44 Z Arpi2007 Addk (eJOI21_addk) C++14
92 / 100
125 ms 8020 KB
#include <iostream>
#include <queue>
#include <sstream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <math.h>
#include <climits>
#include <stdlib.h>
#include <stdio.h>
#include <iomanip>
using namespace std;

#define ll long long
#define ld long double
#define ull unsigned long long
#define ub upper_bound
#define lb lower_bound 
#define ff first
#define ss second
#define mpr make_pair
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define vpi vector<pii>
#define pb push_back
#define pob pop_back
#define mii map<int,int>
#define vpl vector<pair<ll, ll>>
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define sz(x) x.size()
#define clr(x) x.clear()
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define print(x) cout<<"x="<<x<<endl;

ll MOD = 1e9 + 7;
ll MOD2 = 998244353;

void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

/* void setprecision(int x) {

    cout.setf(ios::fixed | ios::showpoint);
    cout.precision(x);
} */

/*void setIO(string name = "") {
    if ((int)name.size() > 0) {
        freopen((name + ".in").c_str(), "r", stdin);
        freopen((name + ".out").c_str(), "w", stdout);
    }
}*/

ll gcd(ll a, ll b)
{
    if (b == 0) {
        return a;
    }
    else {
        return gcd(b, a % b);
    }
}

int num(int n) {
    ll ans = 0;
    while (n != 0) {
        ans++;
        n /= 10;
    }
    return ans;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}


ll factorial(ll n) {
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        ans *= i;
        ans %= MOD2;
    }
    return ans;
}

bool isPrime(int n)
{
    if (n <= 1) {
        return false;
    }
    if (n == 2) {
        return true;
    }
    for (int i = 2; i * i <= n; i++) {
        if (n % i == 0)
            return false;
    }
    return true;
}

int sumnum(int n) {
    int ans = 0;
    while (n != 0) {
        ans += n % 10;
        n /= 10;
    }
    return ans;
}

ll bpow_mod(ll a, ll b, ll mod)
{
    ll ans = 1;
    while (b) {
        if ((b & 1) == 1) {
            ans *= a;
            ans %= mod;
        }
        b >>= 1;
        a *= a;
        a %= mod;
    }
    return ans;
}

int highpow2(int n)
{
    int p = (int)log2(n);
    return (int)pow(2, p);
}

bool sortbysec(const pair<int, int>& a,
    const pair<int, int>& b)
{
    return (a.second < b.second);
}

void precalc() {
    return;
}


const int N = 3e5 + 10;
ll pref[N], prefpref[N];
ll a[N];

void solve(){
    int n, k; cin >> n >> k;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        pref[i] += a[i] + pref[i - 1];
        prefpref[i] += pref[i] + prefpref[i - 1];
        //cout << prefpref[i] << endl;
    }
    int q; cin >> q;
    while(q--){
        int t; cin >> t;
        if(t == 1){
            for(int i = 1; i <= k; ++i){
                int kk; cin >> kk;
            }
        }
        else{
            int l, r, m; cin >> l >> r >> m;
          //  m = min(m, r - l + 1 - m + 1);
            cout << prefpref[r] - prefpref[r - m] - prefpref[l + m - 2] + prefpref[max(l - 2, 0)] << endl;
        }
    }
}

void cases() {
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

int main() {
   // setIO("hps");
    fastio();
    precalc();
    //setprecision(5);
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 2 ms 348 KB Output is correct
3 Correct 3 ms 348 KB Output is correct
4 Correct 4 ms 604 KB Output is correct
5 Correct 5 ms 692 KB Output is correct
6 Correct 7 ms 600 KB Output is correct
7 Correct 7 ms 780 KB Output is correct
8 Correct 11 ms 860 KB Output is correct
9 Correct 12 ms 904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1084 KB Output is correct
2 Correct 41 ms 4180 KB Output is correct
3 Correct 49 ms 4692 KB Output is correct
4 Correct 95 ms 6484 KB Output is correct
5 Correct 125 ms 8020 KB Output is correct
6 Correct 118 ms 7764 KB Output is correct
7 Correct 117 ms 7764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 51 ms 3920 KB Output isn't correct
2 Halted 0 ms 0 KB -