Submission #844596

#TimeUsernameProblemLanguageResultExecution timeMemory
844596XXBabaProBerkayAddk (eJOI21_addk)C++11
0 / 100
57 ms2224 KiB
#pragma GCC optimize("O3") #pragma GCC target("avx2") #include<bits/stdc++.h> using namespace std; #define F first #define S second using ll = long long int; using pi = pair<int,int>; using str = string; const int INF = 1e9 + 7; const int MOD = 998244353; int gcd(int a, int b) { return (b==0) ? a : gcd(b, a%b); } int lcm(int a, int b) { return a*b/gcd(a, b); } int main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n,k; cin >> n >> k; vector<int> a(n+1),pref(n+1, 0),preff(n+1, 0); for(int i=1; i<=n; i++) { cin >> a[i]; pref[i] = pref[i-1] + a[i]; preff[i] = preff[i-1] + pref[i]; } int Q; cin >> Q; while(Q--) { int q; cin >> q; if(q==1) { int x; cin >> x; } else { int l,r,m; cin >> l >> r >> m; int ans = 0; for(int i=r; i>=l+m-1; --i) ans += pref[i]; for(int i=l-1; i<=r-m; i++) ans -= pref[i]; cout << ans << "\n"; } } } // 7 2 5 1 9 3 4 6 // 7 9 14 15 24 27 31 17 // 7 16 30 45 69 96 127 144
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...