#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FORI(i, n) for(int i = 0; i < n; i++)
#define FOR(i, n) for(int i = 1; i <= n; i++)
typedef vector < ll > vl;
typedef set < ll > setl;
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define pll pair < ll , ll >
#define db double
#define nll cout << "\n"
#define nl "\n"
#define sync \
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0) ;
// #define int ll
const ll INF = 1e9;
const int MAX = 1e5 + 5;
ll n, m, k;
ll t[4 * MAX], a[MAX], b[11], pref[MAX];
void solve(){
cin >> n >> k;
FOR(i, n){
cin >> a[i];
}
ll q, c;
cin >> q;
ll l, r, x;
FOR(i, n)pref[i] = pref[i - 1] + a[i];
while(q--){
cin >> c;
if(c == 2){
cin >> l >> r >> x;
ll res = 0;
for(ll i = l; i <= r; i++){
if(i <= r- x + 1)
res += max(0LL, pref[i + x - 1] - pref[i - 1]);
}
cout << res << nl;
}
}
}
signed main(){
sync;
ll t = 1;
// cin >> t;
while(t--){
solve();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
2392 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
190 ms |
2900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
205 ms |
2704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |