DMOPC '14 Contest 2 P6 - Selective Cutting

View as PDF

Submit solution


Points: 12 (partial)
Time limit: 0.25s
Java 1.0s
Python 1.0s
Memory limit: 128M

Authors:
Problem type

The Logging Company has been hit with a petition from concerned citizens regarding their uncontrolled tree-cutting. For public relations purposes, they have decided that, moving forward, they will only cut down trees with mass above a certain threshold.

The Logging Company has a line of N (1N100000) trees. Each tree i has a mass mi (1mi20000). The Company wants to cut some of the trees, so they've hired you to calculate the mass of all the wood they would get from cutting all the trees with mi greater than or equal to q (1q20000) between positions a and b inclusive (0ab<N). In particular, they want you to answer Q (1Q100000) such queries.

Input Specification

The first line will contain the integer N. For each tree i, the ith (from 0) integer on the second line will contain the integer mass mi. The third line will contain the number Q, the number of queries the logging company wants you to answer. The next Q lines will contain three integers a and b and q.

Output Specification

For each query, print the total mass of the trees at position i such that aib, and miq.

Sample Input

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

Sample Output

Copy
12
9
5
5
15

Comments


  • 1
    erniethatrandomguy12  commented on July 26, 2023, 12:16 a.m.

    Is there somewhere you can find test cases for DMOPC problems?


    • 4
      Kirito  commented on July 26, 2023, 1:48 a.m.

      You should learn how to come up with testcases on your own -- after all, most contests won't be nice enough to give you access to their test cases.