#include <cstdint> #include <cstring> #include <iostream> using u32 = std::uint32_t; using u64 = std::uint64_t; int main(void) { u32 t; std::cin >> t; for(u32 i=0; i<t; ++i) { u32 n; std::cin >> n; u32 min_a=1000001, min_b=1000001; u32 max_a=0, max_b=0; u64 sum_a = 0; u64 sum_b = 0; for(u32 j=0; j<n; ++j) { u32 l, a, b; std::cin >> l >> a >> b; if(a < min_a) { min_a = a; } if(b < min_b) { min_b = b; } if(a > max_a) { max_a = a; } if(b > max_b) { max_b = b; } sum_a += l*a; sum_b += l*b; } if(sum_a == sum_b && min_a <= min_b && max_a >= max_b) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } } return 0; }
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 40 41 42 43 44 45 | #include <cstdint> #include <cstring> #include <iostream> using u32 = std::uint32_t; using u64 = std::uint64_t; int main(void) { u32 t; std::cin >> t; for(u32 i=0; i<t; ++i) { u32 n; std::cin >> n; u32 min_a=1000001, min_b=1000001; u32 max_a=0, max_b=0; u64 sum_a = 0; u64 sum_b = 0; for(u32 j=0; j<n; ++j) { u32 l, a, b; std::cin >> l >> a >> b; if(a < min_a) { min_a = a; } if(b < min_b) { min_b = b; } if(a > max_a) { max_a = a; } if(b > max_b) { max_b = b; } sum_a += l*a; sum_b += l*b; } if(sum_a == sum_b && min_a <= min_b && max_a >= max_b) { std::cout << "TAK\n"; } else { std::cout << "NIE\n"; } } return 0; } |