#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pb push_back
#define pf push_front
#define ppb pop_back
#define forik(x) ll i = 1; i <= x; i++
const int mod = 1e9 + 7;
using namespace std;
ll n, k, p[100001], q, a, l, r, m, s[100001], b, pr[100001];
ll gcd (ll a, ll b){
while (a > 0 && b > 0){
if (a >= b){
a %= b;
}
else{
b %= a;
}
}
return a + b;
}
ll binpow(ll a, ll b){
a %= mod;
if(b == 0){
return 1;
}
if(b % 2 == 1){
return binpow (a, b - 1) % mod * a;
}
if(b % 2 == 0){
ll t = binpow(a, b / 2) % mod;
return t * t % mod;
}
}
signed main (){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> k;
for (int i = 1; i <= n; i++){
cin >> p[i];
pr[i] = pr[i - 1] + p[i];
}
cin >> q;
while (q--){
cin >> a;
if (a == 1){
for (int y = 1; y <= k; y++){
cin >> s[y];
}
b = p[s[1]];
for (int y = 1; y < k; y++){
p[s[y]] = p[s[y + 1]];
}
p[s[k]] = b;
for (int i = 1; i <= n; i++){
pr[i] = pr[i - 1] + p[i];
}
cout << '\n';
}
else{
cin >> l >> r >> m;
b = 0;
for (int i = l; i <= r - m + 1; i++){
b += pr[i + m - 1] - pr[i - 1];
}
cout << b << '\n';
}
}
}
Compilation message
Main.cpp: In function 'long long int binpow(long long int, long long int)':
Main.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
42 | }
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
2 ms |
348 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
4 ms |
468 KB |
Output is correct |
7 |
Correct |
5 ms |
468 KB |
Output is correct |
8 |
Correct |
8 ms |
468 KB |
Output is correct |
9 |
Correct |
13 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
42 ms |
912 KB |
Output is correct |
2 |
Correct |
91 ms |
1156 KB |
Output is correct |
3 |
Correct |
168 ms |
1576 KB |
Output is correct |
4 |
Correct |
613 ms |
2460 KB |
Output is correct |
5 |
Correct |
1435 ms |
5872 KB |
Output is correct |
6 |
Correct |
1673 ms |
5524 KB |
Output is correct |
7 |
Correct |
1661 ms |
5588 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
522 ms |
1556 KB |
Output is correct |
2 |
Correct |
980 ms |
5120 KB |
Output is correct |
3 |
Execution timed out |
2062 ms |
6332 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |