이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |