Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
846 B
15
Indexable
Never
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int trees;
    cin >> trees;
    int garden[trees]; 
    int count = 0;
    
    for (int i=0; i<trees; i++) {
        cin >> garden[i];
    }
    
    
    int r;
    cin >> r;
    int rs[r][3];
    for (int i=0; i<r; i++) {
        for (int j=0; j<r; j++){
            cin >> rs[i][j];
        }

    }
    //cout << rs[1][1];
    
    for (int i =0; i<=r; i++) {
        if (rs[i][0] == 1) {
            for (int j=rs[i][1]; j<=rs[i][2]; j++){
                count += garden[j-1];
            }
        }
        if (rs[i][0] == 2) {
            garden[rs[i][1]-1] = rs[i][2];
        }
    }
    cout << count;
    return 0;
}