#include <iostream>
using namespace std;
int N, K, Q, z, n, nuo, iki, sek, ats, sum;
int m[100005];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(nullptr);
cout.tie(nullptr);
cin >> N >> K;
for(int a = 0; a < N; a++)
{
cin >> m[a];
}
cin >> Q;
for(int a = 0; a < Q; a++)
{
cin >> z;
if(z == 1)
{
cin >> n;
n--;
int buv = n, p = m[n];
for(int b = 1; b < K; b++)
{
cin >> n;
n--;
m[buv] = m[n];
// cout << "buv = " << buv << ", m[buv] = " << m[buv] << '\n';
buv = n;
}
m[buv] = p;
// cout << "buv = " << buv << ", m[buv] = " << m[buv] << '\n';
}
if(z == 2)
{
cin >> nuo >> iki >> sek;
nuo--;
iki--;
int pr = 0;
sum = 0;
for(int b = nuo; b <= iki; b++)
{
sum+= m[b];
if(b + nuo - 1 >= sek)
{
ats += sum - pr;
pr += m[b - sek + nuo];
}
// cout << "b = " << b << ", sum = " << sum << ", pr = " << pr << ", ats = " << ats << '\n';
}
cout << ats << '\n';
ats = 0;
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
344 ms |
552 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1546 ms |
1020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |