시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
2 초 | 1024 MB | 30 | 6 | 5 | 41.667% |
You are given an array $A$ of $N$ integers $A_1, \dots , A_N$ and an integer $K$. You must process $Q$ queries of the following two types:
The first line of the input contains two integers, $N$ and $K$. The second line contains $N$ integers: the elements of array $A$. The third line contains an integer $Q$, the number of queries, and next $Q$ lines consists of queries, which can be one of two types described above.
The output consists of the answer to the queries of type $2$, every answer on a new line.
번호 | 배점 | 제한 |
---|---|---|
1 | 36 | $1 ≤ N, Q ≤ 10\,000$, $K = 1$ |
2 | 56 | $10\,001 ≤ N, Q ≤ 100\,000$, $K = 1$ |
3 | 8 | $1 ≤ N, Q ≤ 100\,000$, $2 ≤ K ≤ 10$ |
8 3 7 2 5 1 9 3 4 6 3 2 2 7 4 1 2 5 8 2 2 7 3
52 50
The first query is of type $2$ and we must calculate the sum of elements of all continuous subsequences with length $m = 4$ from sequence $(2, 5, 1, 9, 3, 4)$. These subsequences are $(2, 5, 1, 9)$, $(5, 1, 9, 3)$, $(1, 9, 3, 4)$, and the sum of their elements is 52.
The second query is of type $1$ and requires the circular permutation of elements from array $A$, situated at indexes $2$, $5$, $8$. So, the array $A$ will become $(7, 9, 5, 1, 6, 3, 4, 2)$.
The third query is of type $2$ and we must calculate the sum of elements of all continuous subsequences with length $m = 3$ from sequence $(9, 5, 1, 6, 3, 4)$. These subsequences are $(9, 5, 1), (5, 1, 6), (1, 6, 3), (6, 3, 4)$, and the sum of their elements is $50$.