fork download
  1. #include<iostream>
  2.  
  3. #define MaxM 1005
  4. bool painted[MaxM] = {false};
  5.  
  6. int main() {
  7. freopen("ROBOT.INP", "r", stdin);
  8. freopen("ROBOT.OUT", "w", stdout);
  9.  
  10. int M, N; std::cin >> M >> N;
  11. for(int i = 1; i <= N; ++i) {
  12. int a, b; std::cin >> a >> b;
  13. for(int j = a; j <= b; ++j) painted[j] = true;
  14. }
  15.  
  16. int res = 0;
  17. for(int i = 1; i <= M; ++i)
  18. if(!painted[i]) ++res;
  19.  
  20. std::cout << res;
  21.  
  22. return 0;
  23. }
  24.  
Success #stdin #stdout 0s 5308KB
stdin
Standard input is empty
stdout
Standard output is empty