#include <iostream> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; ++i){ int n; cin >> n; long long aSum = 0; long long bSum = 0; int aMin = 1000000, aMax = 1, bMin = 1000000, bMax = 1; int l; int a; int b; for (int j = 0; j < n; ++j){ cin >> l >> a >> b; aSum += l * a; bSum += l * b; if (a < aMin) aMin = a; if (a > aMax) aMax = a; if (b < bMin) bMin = b; if (b > bMax) bMax = b; } if (aSum == bSum && aMin <= bMin && aMax >= bMax) cout << "TAK" << endl; else cout << "NIE" << endl; } 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 46 47 | #include <iostream> using namespace std; int main(){ int t; cin >> t; for (int i = 0; i < t; ++i){ int n; cin >> n; long long aSum = 0; long long bSum = 0; int aMin = 1000000, aMax = 1, bMin = 1000000, bMax = 1; int l; int a; int b; for (int j = 0; j < n; ++j){ cin >> l >> a >> b; aSum += l * a; bSum += l * b; if (a < aMin) aMin = a; if (a > aMax) aMax = a; if (b < bMin) bMin = b; if (b > bMax) bMax = b; } if (aSum == bSum && aMin <= bMin && aMax >= bMax) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |