This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f first
#define s second
mt19937 gnd(time(NULL));
void solve(){
int n, m;
cin >> n >> m;
int ans = 0;
vector<int> v(n-1);
for(int i = 0; i < n-1; i++){
int a, b;
cin >> a >> b;
cin >> v[i];
ans+=v[i];
}
int q;
cin >> q;
while(q--){
int r, p;
cin >> r >> p;
ans-=v[r-1];
v[r-1]=p;
ans+=p;
cout << ans << endl;
}
}
signed main(){
int t = 1;
// cin >> t;
while(t--) solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |