-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputador.cpp
49 lines (45 loc) · 972 Bytes
/
computador.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
// iagorrr ;)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n, m;
cin >> n >> m;
vll a(n+1, 0);
/*
1 = frente
2 = tras
3 = imprime
*/
while(m--){
ll I, V, P;
cin >> P;
if(P != 3) cin >> I >> V;
else cin >> I;
switch (P){
case 1:
while(I <= n && V){
a[I] += V;
I++;
V--;
}
break;
case 2:
while(I >= 1 && V){
a[I] += V;
I--;
V--;
}
break;
case 3:
cout << a[I] << '\n';
break;
default:
break;
}
}
return 0;
}
// 20/100 TLE