QOJ.ac

QOJ

実行時間制限: 5 s メモリ制限: 512 MB 満点: 100

#18791. Ciąg i Zapytanie 33

統計

Dany jest ciąg $A_1, A_2, \ldots, A_N$ o długości $N$. Napisz program wykonujący następujące zapytania:

  • l r k: Dla podciągu $A_l, A_{l+1}, \ldots, A_r$ wybierz z niego $k$ niepustych i nienachodzących na siebie podciągów i wypisz maksymalną możliwą sumę elementów tych podciągów.

Wejście

Pierwszy wiersz zawiera dwie liczby całkowite $N$ i $M$, oznaczające długość ciągu oraz liczbę zapytań. ($1 \le N, M \le 35\,000$)

Drugi wiersz zawiera $N$ liczb całkowitych $A_1, A_2, \ldots, A_N$. ($-35\,000 \le A_i < 35\,000$)

Następne $M$ wierszy zawiera po jednym zapytaniu. ($1 \le l \le r \le N$, $1 \le k \le r - l + 1$)

Wyjście

Dla każdego zapytania wypisz wiersz z odpowiedzią.

Przykład

Wejście 1

5 5
-1 2 -3 4 -5
1 5 1
1 5 2
1 5 3
1 5 4
1 5 5

Wyjście 1

4
6
5
2
-3

Wejście 2

5 1
7 7 7 7 7
1 5 1

Wyjście 2

35

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.