## DMOPC '14 Contest 2 P4 - Deforestation

View as PDF

Points: 7 (partial)
Time limit: 5.0s
Memory limit: 256M

Authors:
Problem type

The Logging Company has a long line of trees numbered from to . Each tree has a mass . The Company wants to cut some of the trees, so they hired you to calculate the mass of all the wood they would get from cutting all the trees between positions and inclusive . In particular, they want you to answer such queries.

#### Input Specification

• First line: .
• Lines to : line is the mass of tree , .
• The line will contain the integer , the number of queries the logging company wants answered.
• The next lines will contain the integers and .

#### Output Specification

For each query, print the total mass of the trees at position such that .

#### Scoring

• For 30% of the points, .
• For 50% of the points, .
• For the rest, .

#### Sample Input

5
1
2
3
4
5
3
0 4
1 3
2 2

#### Sample Output

15
9
3

• TypicalToxic  commented on May 12, 2016, 12:18 p.m.

An internal error occurred while grading, and the DMOJ administrators have been notified. In the meantime, try resubmitting in a few seconds.

• Xyene  commented on May 12, 2016, 2:33 p.m.

Yes, we all get an email whenever an IE occurs. I've fixed the issue, and the problem is working now.

• FatalEagle  commented on Oct. 9, 2015, 11:50 p.m.

cin/cout might be too slow to pass. Try one of the tips!

• Kirito  commented on May 14, 2016, 5:13 p.m.

Is this question doable in Turing with the current time limit?

• Xyene  commented on May 14, 2016, 5:23 p.m. edited

The OpenTuring we use includes some benchmarks against Python in its README, which might be of help.

Conclusion

Python is faster than Turing.

• quantum  commented on Nov. 18, 2014, 11:22 p.m.

Give PYPY a try. (Why must I rhyme?)

• FatalEagle  commented on Nov. 20, 2014, 12:30 p.m.

Specifically, if you TLE with CPython, use the Pypy interpreter.