-
Notifications
You must be signed in to change notification settings - Fork 0
/
295A.cpp
55 lines (46 loc) · 874 Bytes
/
295A.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int main()
{
ll n , m ,k;
cin >> n >> m >> k;
ll a[n];
for(int i = 0 ; i < n ; i ++)
cin >> a[i];
ll a1[m][3];
for(int i = 0 ; i < m ; i ++)
{
cin >> a1[i][0] >> a1[i][1] >> a1[i][2];
}
ll ca1[m + 2] = {0};
for(int i = 0 ; i < k ; i++)
{
ll x, y;
cin >> x >> y;
ca1[x]++;
ca1[y + 1]--;
}
ll total = 0;
for(int i = 1 ; i <= m ; i ++)
{
total += ca1[i];
ca1[i] = total;
}
ll ca2[n + 2] = {0};
for(int i = 0 ; i < m ; i ++)
{
a1[i][2] = a1[i][2] * ca1[i + 1];
ca2[a1[i][0]]+= a1[i][2];
ca2[a1[i][1] + 1]-= a1[i][2];
}
total = 0;
for(int i = 0 ; i < n ; i ++)
{
total += ca2[i + 1];
a[i] += total;
}
for(auto x : a)
cout << x << " ";
}