Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int q, x, y, z, smen[103], v[103];
- int main()
- {
- int n;
- cout << "n=";
- cin >> n;
- cout << "v:";
- for (int i = 1; i <= n; i++)
- cin >> v[i];
- cout << "q=";
- cin >> q;
- while (q--)
- {
- cin >> x >> y >> z; // aduna intre [x, y] valoarea z
- smen[x] += z;
- smen[y + 1] -= z;
- }
- /* for (int i =0;i<=n;i++)cout<<smen[i]<<' ';
- cout<<endl;//*/
- for (int i = 1; i <= n; ++i)
- {
- smen[i] += smen[i - 1];
- }
- for (int i = 1; i <= n; i++)
- {
- v[i] += smen[i];
- }
- cout << "after smen:" << endl;
- for (int i = 1; i <= n; i++)
- cout << v[i] << ' ';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement