Submission #763927

#TimeUsernameProblemLanguageResultExecution timeMemory
763927CookieAddk (eJOI21_addk)C++14
36 / 100
2074 ms3004 KiB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
const int mxn = 1e5 + 5;
int n, k;
ll a[mxn + 1];
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)cin >> a[i];
    int q; cin >> q;
    for(int i = 1; i <= q; i++){
        int idq; cin >> idq;
        if(idq == 1){
            for(int j = 0; j < k; j++){
                int x; cin >> x;
            }
        }else{
            int l, r, m; cin >> l >> r >> m;
            ll ans = 0;
            for(int j = l; j <= r; j++){
                int low = max(j - m + 1, l), high = min(r - m + 1, j);
                ans += 1LL * (high - low + 1) * a[j];
            }
            cout << ans << "\n";
        }
    }
    return(0);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...