## GlobeX Cup '19 S4 - Ninjaclasher's Wrath 2

View as PDF

Points: 25 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

You may have heard of "spooky action at a distance", or you may have not. It doesn't matter. There exists a line of particles, of which the particle and the particle are quantum entangled. Note that what is described in this problem is not how quantum entanglement really works. Each particle has an electric charge . You happen to know the electric charges of all particles in order.

When you look at a particle , due to the fact that it is entangled, it will instantaneously have the charge of particle , and particle will have the charge of particle . You can only look at a maximum of particles before you become blinded. Thus, you are curious: what is the maximum sum of the charges of the particles to , inclusive, if I look at EXACTLY particles? Note that you can look at a particle at one position multiple times.

You must answer of these questions. These questions must be answered online.

#### Input Specification

The first line will contain three integers .

The second line will contain integers, .

The next lines will each contain two integers, , a question as defined above.

After each question, you must output the answer before you will receive the next question. In some languages, you may need to flush in order for the interactor to receive your answer. The interactor may take up to 1.5 seconds of the time limit.

#### Output Specification

Output lines. On the line, output one integer: the maximum sum of charges of the particles in .

No further constraints.

#### Sample Input 1

7 3 5
3 4 -5 8 3 1 0
1 3
1 4
2 7
3 6
3 3

#### Sample Output 1

10
18
14
10
3

#### Explanation For Sample 1

For the first question, if we choose and look times, we get the line of particles 3 4 3 8 -5 1 0, whose sum of charges from to is . It turns out, this is the maximum possible sum.
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.5504140853881836, "perplexity": 1820.7188866781562}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2020-45/segments/1603107898577.79/warc/CC-MAIN-20201028132718-20201028162718-00117.warc.gz"}