#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int t, n; long long l, a, b; long long sumaA, sumaB, minA, maxA, minB, maxB; cin >> t; for(int iT = 0; iT < t; ++iT) { sumaA = sumaB = 0; minA = minB = 9999999; maxA = maxB = 0; cin >> n; for(int iN = 0; iN < n; ++iN){ cin >> l >> a >> b; sumaA += l * a; sumaB += l * b; minA = min(minA, a); maxA = max(maxA, a); minB = min(minB, b); maxB = max(maxB, b); } if( sumaA == sumaB && minA <= minB && maxA >= maxB) 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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); int t, n; long long l, a, b; long long sumaA, sumaB, minA, maxA, minB, maxB; cin >> t; for(int iT = 0; iT < t; ++iT) { sumaA = sumaB = 0; minA = minB = 9999999; maxA = maxB = 0; cin >> n; for(int iN = 0; iN < n; ++iN){ cin >> l >> a >> b; sumaA += l * a; sumaB += l * b; minA = min(minA, a); maxA = max(maxA, a); minB = min(minB, b); maxB = max(maxB, b); } if( sumaA == sumaB && minA <= minB && maxA >= maxB) cout << "TAK" << endl; else cout << "NIE" << endl; } return 0; } |