Advertisement
Guest User

Untitled

a guest
Oct 30th, 2018
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int N, M, i, j;
  5. cin >> N >> M;
  6. int snow[10000] = {};
  7. for (i = 0; i <= N; i++) {
  8. snow[i] = 0;
  9. }
  10. for (i = 0; i < M; i++) {
  11. int comm, a, b, c;
  12. cin >> comm;
  13. if (comm == 1) {
  14. cin >> a >> b >> c;
  15. for (j = a; j < b; j++) {
  16. snow[j] = snow[j] + c;
  17. }
  18. }
  19. if (comm == 2) {
  20. cin >> a >> b;
  21. int summ=0;
  22. for (j = a; j < b; j++) {
  23. summ = summ + snow[j];
  24. }
  25. cout << summ << endl;
  26. }
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement