Submission #765948

# Submission time Handle Problem Language Result Execution time Memory
765948 2023-06-25T08:04:21 Z vjudge1 Addk (eJOI21_addk) C++17
92 / 100
1191 ms 3676 KB
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define len(x) (int)x.size()
#define ull unsigned long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
// #define int long long

using namespace std;
using namespace __gnu_pbds;
using ll = long long;

const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
ll n,k,q,a[N],p[N],t,sum,l,r,m,x;

main(){
	// freopen("txt.in", "r", stdin);
	// freopen("txt.out", "w", stdout);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> n >> k;
	for (int i=1;i<=n;i++){
		cin >> a[i];
		p[i] = p[i-1] + a[i];
	}
	cin >> q;
	while(q--){
		cin >> t;
		if (t==1){
			for (int i=1;i<=k;i++) cin >> x;
		}
		else{
			cin >> l >> r >> m;
			sum = 0;
			for (int i=l+m-1;i<=r;i++){
				sum+=p[i] - p[i-m];
			}
			cout << sum << '\n';
		}
	}
}

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).

//sum of squares n*(n+1)*(2n+1)/6
//sum of cubes [n*(n+1)/2]^2
//sum of squares for odds n*(4*n*n-1)/3
//sum of cubes for odds n*n*(2*n*n-1)

//a/b%mod = a*(b^(m-2)%mod)
//(a>>x)&1 == 0
//a^b = (a+b)-2(a&b)

//srand(time(0))-always changing

Compilation message

Main.cpp:26:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   26 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 3 ms 468 KB Output is correct
5 Correct 3 ms 468 KB Output is correct
6 Correct 4 ms 588 KB Output is correct
7 Correct 5 ms 568 KB Output is correct
8 Correct 7 ms 596 KB Output is correct
9 Correct 11 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 916 KB Output is correct
2 Correct 71 ms 1288 KB Output is correct
3 Correct 135 ms 1700 KB Output is correct
4 Correct 487 ms 2480 KB Output is correct
5 Correct 1191 ms 3676 KB Output is correct
6 Correct 1092 ms 3588 KB Output is correct
7 Correct 1107 ms 3524 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 203 ms 1572 KB Output isn't correct
2 Halted 0 ms 0 KB -