-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1679B_Stone-Age-Problem.cpp
56 lines (51 loc) · 1.04 KB
/
1679B_Stone-Age-Problem.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
56
#include <bits/stdc++.h>
#define int long long
#define X first
#define Y second
#define Cheng0928 ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE(a) signed(a.size())
using namespace std;
void sol(){
int n, q;
cin >> n >> q;
vector<pair<int,int>> a;// x, t
int sum = 0;
for(int i = 0;i<n;i++){
int x;
cin >> x;
a.push_back({x,0});
sum+=x;
}
pair<int,int> change = {0, -1};
for(int i = 1;i<=q;i++){
int t;
cin >> t;
if(t == 1){
int p, x;
cin >> p >> x;
p--;
if(a[p].second < change.second){
sum+=(x-change.first);
}
else{
sum+=(x-a[p].first);
}
a[p] = {x, i};
}
else{
int x;
cin >> x;
change = {x, i};
sum = x*n;
}
cout << sum << '\n';
}
}
signed main()
{
Cheng0928
/*int t;
cin >> t;
while(t--)*/ sol();
return 0;
}