Skip to content

Commit 3ca7552

Browse files
authored
Create 270254V. No standard.cpp
1 parent 6ceee1b commit 3ca7552

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <bits/stdc++.h>
2+
3+
using namespace std;
4+
5+
int const N = 1e6 + 10;
6+
int n, m, s, e;
7+
long long a[N], cs[N], ranges[N], ones, cnt, res[N];
8+
9+
int main() {
10+
scanf("%d %d", &n, &m);
11+
12+
for (int i = 1; i <= n; ++i) {
13+
scanf("%d", a + i);
14+
}
15+
16+
while (m-- != 0) {
17+
scanf("%d %d", &s, &e);
18+
cs[s] += 1;
19+
cs[e + 1] -= 1;
20+
ranges[e + 1] += e - s + 1;
21+
}
22+
23+
for(int i = 1; i <= n; ++i) {
24+
ones += cs[i];
25+
cnt -= ranges[i];
26+
cnt += ones;
27+
28+
res[i] = a[i] + cnt;
29+
}
30+
31+
for(int i = 1; i <= n; ++i) {
32+
printf("%lld ", res[i]);
33+
}
34+
puts("");
35+
36+
return 0;
37+
}

0 commit comments

Comments
 (0)