fork download
  1. #include <stdio.h>
  2. #define SIZE 10000
  3.  
  4. int hi[SIZE];
  5.  
  6. int main(void)
  7. {
  8. int i, L, H, R, maxR = 0;
  9.  
  10. while (scanf("%d %d %d", &L, &H, &R) == 3) {
  11. for (i = L; i < R; i++) {
  12. if (H > hi[i])
  13. hi[i] = H;
  14. }
  15. if (R > maxR)
  16. maxR = R;
  17. }
  18.  
  19. for (i = 1; i <= maxR; i++)
  20. if (hi[i] != hi[i - 1])
  21. printf("%d,%d ", i, hi[i]);
  22. //printf("%d \n", maxR);
  23. return 0;
  24. }
Success #stdin #stdout 0s 2200KB
stdin
1 11 5  
2 6 7 
3 13 9  
12 7 16  
14 3 25  
19 18 22  
23 13 29  
24 4 28
stdout
1,11 3,13 9,0 12,7 16,3 19,18 22,3 23,13 29,0