#include <iostream> int main(){ long int containers, size; long int beg, end, temp; short color; temp = 0; std::cin >> containers >> size; int *str = new int[containers]; for(int i = 0; i < containers; i++) str[i] = 0; while(size--){ std::cin >> beg >> end >> color; for(int i = beg-1; i < end; i++){ str[i] += (color * 10) + 1; if(str[i] == 32) temp++; } } std::cout << temp << std::endl; return 0; } /* 9 5 2 8 1 4 5 2 6 7 3 5 6 2 1 2 2 */
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #include <iostream> int main(){ long int containers, size; long int beg, end, temp; short color; temp = 0; std::cin >> containers >> size; int *str = new int[containers]; for(int i = 0; i < containers; i++) str[i] = 0; while(size--){ std::cin >> beg >> end >> color; for(int i = beg-1; i < end; i++){ str[i] += (color * 10) + 1; if(str[i] == 32) temp++; } } std::cout << temp << std::endl; return 0; } /* 9 5 2 8 1 4 5 2 6 7 3 5 6 2 1 2 2 */ |