Battle Positions

View as PDF

Submit solution

Points: 7
Time limit: 0.1s
Java 0.6s
Python 0.6s
Memory limit: 128M

Author:
Problem type

The ZAFT are attacking the Orb Union! There are II stations, numbered from 1, 2, \dots, I1, 2, \dots, I, that need to be defended. For it to be secure, the Orb Union needs to have at least NN troops at each station. Unfortunately, due to the radar-jamming effects of the Neutron Jammer, the Orb Union cannot order their troops to move between stations. The Orb Union will send JJ waves of troops, each of which sends KK troops to each of the stations X_i, X_{i+1}, \dots, X_fX_i, X_{i+1}, \dots, X_f. All stations start with 00 troops.

The Orb Union wants you to help them find the number of stations that are not secure.

Input Specification

The first line will contain the integer II (1 \le I \le 10^5)(1 \le I \le 10^5), the number of stations.

The second line will contain the integer NN (1 \le N \le 10^9)(1 \le N \le 10^9), the minimum number of troops required to defend a station.

The third line will contain the integer JJ (1 \le J \le 10^5)(1 \le J \le 10^5), the number of waves of troops.

The next JJ lines will contain 3 space-separated integers. These integers will be in the order X_iX_i, X_fX_f, KK (1 \le X_i \le X_f \le I)(1 \le X_i \le X_f \le I) (1 \le K \le 10^4)(1 \le K \le 10^4).

Output Specification

Output the total number of stations that have less than NN troops.

Sample Input

4
1
3
1 3 1
2 3 2
3 3 2

Sample Output

1

Explanation for Sample Output

Station 1 has 1 troop, station 2 has 3 troops, station 3 has 5 troops and station 4 has 0 troops. Station 4 is the only station with less than 1 troop, so the output is 1.


Comments


  • -15
    Narcariel  commented on Dec. 18, 2020, 5:40 p.m. edited

    This comment is hidden due to too much negative feedback. Click here to view it.


  • -32
    Plasmatic  commented on March 18, 2017, 10:56 a.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


  • -27
    Oppenheimer  commented on Dec. 31, 2014, 9:34 p.m.

    This comment is hidden due to too much negative feedback. Click here to view it.


    • -20
      Xyene  commented on Dec. 31, 2014, 9:38 p.m.

      This comment is hidden due to too much negative feedback. Click here to view it.


      • -27
        Oppenheimer  commented on Dec. 31, 2014, 9:42 p.m.

        This comment is hidden due to too much negative feedback. Click here to view it.


    • -20
      Xyene  commented on Dec. 31, 2014, 9:35 p.m.

      This comment is hidden due to too much negative feedback. Click here to view it.