#include <iostream> #include <cstdio> using namespace std; int main() { int t, n, l, a, b; scanf("%d", &t); while (t--) { long long A = 0, B = 0; int minA = 1000000, minB = 1000000; int maxA = 0, maxB = 0; scanf("%d", &n); while (n--) { scanf("%d%d%d", &l, &a, &b); A += (long long)l * a; B += (long long)l * b; minA = min(minA, a); minB = min(minB, b); maxA = max(maxA, a); maxB = max(maxB, b); } printf("%s\n", (A == B && minA <= minB && maxB <= maxA) ? "TAK" : "NIE"); } }
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 | #include <iostream> #include <cstdio> using namespace std; int main() { int t, n, l, a, b; scanf("%d", &t); while (t--) { long long A = 0, B = 0; int minA = 1000000, minB = 1000000; int maxA = 0, maxB = 0; scanf("%d", &n); while (n--) { scanf("%d%d%d", &l, &a, &b); A += (long long)l * a; B += (long long)l * b; minA = min(minA, a); minB = min(minB, b); maxA = max(maxA, a); maxB = max(maxB, b); } printf("%s\n", (A == B && minA <= minB && maxB <= maxA) ? "TAK" : "NIE"); } } |