Submission #1071443

# Submission time Handle Problem Language Result Execution time Memory
1071443 2024-08-23T07:27:02 Z vjudge1 Addk (eJOI21_addk) C++
36 / 100
2000 ms 5452 KB
// Balgabaev Mansur
#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
#define pb push_back
#define int long long


using namespace std;

const int N=1e6+7;
const int MOD=1e9+7;
const int INF=1e18;

int binpow (int a, int n) {
	if (n == 0)
		return 1;
	if (n % 2 == 1)
		return binpow (a, n-1) * a;
	else {
		int b = binpow (a, n/2);
		return b * b;
	}
}

int a[N],pref[N];

void solve(){
	int n,k;
	cin >> n >> k;
	for(int i = 1 ; i <= n ; i++){
		cin >> a[i];
		pref[i]=pref[i-1]+a[i];
	}	
	int q;
	cin >> q;
	while(q--){
		int tp,l,r,x,ans=0;
		cin >> tp;
		if(tp == 1){
			cin >> x;
		}
		if(tp == 2){
			cin >> l >> r >> x;
			for(int i = l ; i <= r ; i++){
				if(i+x-1 <= r){
					ans+=pref[i+x-1]-pref[i-1];
				}
			}
			cout << ans << '\n';
		}
	}
}	
 
signed main() {
   // freopen("closing.in", "r", stdin);
   // freopen("closing.out", "w", stdout);
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int test = 1,cntx=1;
    //cin >> test;
    while (test--) {
	//cout << "Case " << 	cntx << ':' << '\n';
        solve();
        cntx++;
	}		
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 2 ms 2392 KB Output is correct
3 Correct 3 ms 2396 KB Output is correct
4 Correct 5 ms 2396 KB Output is correct
5 Correct 9 ms 2396 KB Output is correct
6 Correct 20 ms 2396 KB Output is correct
7 Correct 19 ms 2648 KB Output is correct
8 Correct 26 ms 2648 KB Output is correct
9 Correct 51 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 201 ms 2688 KB Output is correct
2 Correct 516 ms 5012 KB Output is correct
3 Correct 791 ms 5072 KB Output is correct
4 Execution timed out 2043 ms 5452 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 219 ms 4748 KB Output isn't correct
2 Halted 0 ms 0 KB -