assign a value in range in each query in the end print the sum of the array elements
| 48 | //assign a value in range in each query |
| 49 | //in the end print the sum of the array elements |
| 50 | int32_t main() { |
| 51 | int i, j, k, n, m, q, l, r, v; |
| 52 | cin >> n >> q; |
| 53 | se.init(n); |
| 54 | while(q--) { |
| 55 | cin >> l >> r >> v; |
| 56 | se.assign(l, r, v); |
| 57 | } |
| 58 | int ans = 0; |
| 59 | for(auto x : se.value) { |
| 60 | ans += 1LL * ((x.first.first - x.first.second + 1) % mod) * (x.second % mod) % mod; |
| 61 | ans %= mod; |
| 62 | } |
| 63 | cout << ans << endl; |
| 64 | return 0; |
| 65 | } |