-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShaassAndOskols.cpp
More file actions
42 lines (31 loc) · 863 Bytes
/
ShaassAndOskols.cpp
File metadata and controls
42 lines (31 loc) · 863 Bytes
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
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
int n, m;
scanf("%d", &n);
int *wires = new int[n + 1];
for(int i = 1; i <= n; i++) {
scanf("%d", &wires[i]);
}
scanf("%d", &m);
int wire, bird, upperWire, lowerWire, goToupperBird, goTolowerBird;
for(int i = 0; i < m; i++) {
scanf("%d %d", &wire, &bird);
upperWire = wire - 1;
lowerWire = wire + 1;
goToupperBird = bird - 1;
goTolowerBird = wires[wire] - bird;
if(upperWire != 0 && goToupperBird > 0) {
wires[upperWire] += goToupperBird;
}
if(lowerWire != n + 1 && goTolowerBird > 0) {
wires[lowerWire] += goTolowerBird;
}
wires[wire] = 0;
}
for(int i = 1; i <= n; i++) {
printf("%d\n", wires[i]);
}
return 0;
}