fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, q;
  6. cin >> n >> q;
  7.  
  8. int arr[n] = {0};
  9.  
  10. while (q--) {
  11. int l, r;
  12. cin >> l >> r;
  13.  
  14. for (int j = l; j <= r; j++) {
  15. arr[j] = arr[j] + 1;
  16. }
  17. }
  18.  
  19. for (int i = 0; i < n; i++) {
  20. cout << arr[i] << " ";
  21. }
  22.  
  23. cout << endl;
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 5320KB
stdin
10
2
2 5
3 8
stdout
0 0 1 2 2 2 1 1 1 0