Hihocoder Challenge 1 * * * * *

Source: Internet
Author: User

#1034: Destroyer problem time limit:10000msSingle Point time limit:1000msMemory Limit:256MBDescribe

In the frozen Throne of Warcraft III, the destroyer was a magical flying unit that killed three of late-night.

One of the core skills of the destroyer, called magical absorption (absorb Mana):

Now let's consider the following question:

Suppose you have n Magical units, and they stand on a line from left to right, numbering from 1 to n. Each unit has three properties:

    • s i: initial mana.

    • m i: Maximum mana limit.

    • R i: Mana recovery rate per second.

Now you manipulate a destroyer, have m operations,T l R, denote moment T, destroyer to all numbering from l to R Unit, using a magical absorption. The operation is given in chronological order to calculate how much mana the destroyer has absorbed.

Input

The first line of the input data has an integer N (1≤ n ≤105 )-The number of your magical units.

n lines with three integers per line s i , m i , R i ( s i m i ≤105, 0≤ R Sub class= "Lower-index" > i ≤105) describes a magic unit.

next line, another integer. M (1≤ m ≤105)-the number of operations.

The next m -line, each line describes an operation t, l, R(0≤ t ≤109, 1≤ lrn),T non-descending.

Output

The output line of an integer indicates how much mana the destroyer absorbed.

Sample input
50 10 10 12 10 20 10 12 10 10 125 1 519 1 5
Sample output
83

Hihocoder Challenge 1 * * * * *

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.