#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, n; int l, a, b, minA, maxA, minB, maxB; int balance; cin >> t; while(t--) { minA = minB = 1000000; maxA = maxB = 0; balance = 0; cin >> n; while (n--) { cin >> l >> a >> b; balance += l * (b - a); minA = min(minA, a); maxA = max(maxA, a); minB = min(minB, b); maxB = max(maxB, b); } cout << ((balance == 0 && minB >= minA && maxB <= maxA) ? "TAK\n" : "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 | #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t, n; int l, a, b, minA, maxA, minB, maxB; int balance; cin >> t; while(t--) { minA = minB = 1000000; maxA = maxB = 0; balance = 0; cin >> n; while (n--) { cin >> l >> a >> b; balance += l * (b - a); minA = min(minA, a); maxA = max(maxA, a); minB = min(minB, b); maxB = max(maxB, b); } cout << ((balance == 0 && minB >= minA && maxB <= maxA) ? "TAK\n" : "NIE\n"); } return 0; } |