## Marathon

View as PDF

Points: 7 (partial)
Time limit: 1.0s
Memory limit: 128M

Authors:
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
##### Prep 4

It was a peaceful day in the life of a student, when suddenly Timothy Li messages you about some strange anime called Date a Live. There are episodes in the series, and each episode has a rating from 1 to 10. Being super bored, you decide to give it a try. Unfortunately, you cannot live without food through the entire afternoon and the anime streamer you are using does not have a pause button for some reason. Thus, to make an intelligent decision on when to go make food, you have queries in the form . For each of these queries, you will simulate skipping episodes to (inclusive), and output the sum of the ratings of the episodes you do not skip.

#### Input Specification

The first line of input contains 2 integers, space separated — .

The next line contains integers, space separated. The of these integers represents the rating of the episode.

The next lines will contain integers and , the episodes that are skipped.

#### Output Specification

For each query, output one integer, the sum specified in the problem statement.

#### Sample Input

10 3
5 6 7 8 3 4 5 6 1 2
1 3
2 4
1 10

#### Sample Output

29
26
0

#### Explanation of Output for Sample Input

For the first query, the first three episodes will be skipped, so the total rating is .

• commented on May 21, 2017, 8:11 p.m.

I have a question regarding my submissions. I submitted the exact same code line for line 3 different times, and one on one of them, I got 5/10 AC (with the others being TLE), on one of them I got 6/10 AC (with the others being TLE), and on the last I got 7/10 AC (with the others being TLE). Does anyone know why this may be?

• commented on July 16, 2017, 7:55 p.m.

The different judges might operate at varying speeds.I think we're in the same boat: I implemented what the editorial called for, yet still, I got TLE on the last three :/

• commented on April 2, 2015, 5:07 p.m. edit 2

For python/all users, it may/may not be advantageous to use fast input :)

• commented on April 2, 2015, 6:00 p.m. edit 4

Thanks Weiwei!