Submission #1034957

#TimeUsernameProblemLanguageResultExecution timeMemory
1034957christinelynnAddk (eJOI21_addk)C++17
36 / 100
2070 ms4716 KiB
#include <bits/stdc++.h> typedef long double ld; #define int long long #define TC int t; cin >> t; for(int _=1; _<=t; _++) #define bismillah ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define pii pair<int, int> #define pb push_back #define mp make_pair using namespace std; const int N = 1e5+7; int a[N], pref[N]; int getsum(int l, int r, int m){ int ret = 0; for(int i=l+m-1, b=l; i<=r; i++, b++){ ret+=(pref[i]-pref[b-1]); }return ret; } signed main(){ bismillah; int n, k; cin >> n >> k; for(int i=1; i<=n; i++){ cin >> a[i]; } for(int i=1; i<=n; i++){ pref[i] = pref[i-1]+a[i]; } int q; cin >> q; while(q--){ int t; cin >> t; if(t==1){ // k=1 > will remain unchanged int x; cin >> x; }else{ int l, r, m; cin >> l >> r >> m; cout << getsum(l, r, m) << '\n'; } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...