Submission #1035924

#TimeUsernameProblemLanguageResultExecution timeMemory
1035924devariaotaAddk (eJOI21_addk)C++17
36 / 100
2061 ms5052 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const ll maxn = 1e6; ll n, k; ll arr[maxn]; ll pref[maxn]; ll q; int main(){ cin >> n >> k; for(ll i = 1; i <= n; i++){ cin >> arr[i]; pref[i] = arr[i]; pref[i] += pref[i-1]; } cin >> q; while(q--){ ll quer; cin >> quer; if(quer == 2){ ll l, r, m; cin >> l >> r >> m; ll hasil = 0; // cerr << "l & r : " << l << " " << r-m+1 << endl; for(ll i = l; i <= r-m+1; i++){ // cerr << "pref : " << pref[i+m-1] << " - " << pref[i-1] << endl; hasil += pref[i+m-1] - pref[i-1]; // cerr << "hasil : " << hasil << endl; } cout << hasil << endl; }else{ ll x; for(ll i = 0; i < k; i++) cin >> x; } } // for(ll i = 1; i <= n; i++) cerr << pref[i] << " "; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...