#include <bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define str string
#define pb push_back
#define pf push_front
#define nl "\n"
#define ll long long
// #define int long long
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
#define len(a) a.size()
#define pii pair<int,int>
const int N = 50000 + 101;
const int md = 998244353;
const int MOD = 1e8;
const int mega = 1e6 + 3;
const int inf = 1e9;
ll gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(int a, int b) {
return (a / gcd(a, b)) * b;
}
void solve() {
int n , k;
cin >> n >> k;
int a[n + 1];
for(int i = 1; i <= n; ++i)cin >> a[i];
int m;
cin >> m;
while(m--){
int ty;
cin >> ty;
if(ty == 2){
int l , r , m;
cin >> l >> r >> m;
int ans = 0;
int pref[n + 1];
pref[0] = 0;
for (int i = l; i <= r; ++i) pref[i] = pref[i - 1] + a[i];
for (int i = l; i <= r; ++i) {
if (i <= r - m + 1) ans += pref[i + m - 1] - pref[i - 1];
}
cout << ans << "\n";
}
else{
int nega;
cin >> nega;
}
}
}
signed main() {
SPEED;
int t = 1;
// cin >> t;
while (t--) {
solve();
}
#ifndef ONLINE_JUDGE
cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
4 ms |
532 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
336 ms |
1244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
264 ms |
1972 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |