#include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int Z; cin >> Z; for(int z = 0; z < Z; z++){ int N; cin >> N; long long w = 0; int minT1 = 1000 * 1000 + 1, minT2 = 1000 * 1000 + 1; int maxT1 = 0, maxT2 = 0; for(int i = 0; i < N; i++){ int v, t1, t2; cin >> v >> t1 >> t2; w += (long long)v * t1; w -= (long long)v * t2; minT1 = min(minT1, t1); minT2 = min(minT2, t2); maxT1 = max(maxT1, t1); maxT2 = max(maxT2, t2); } bool t = 1; if(minT2 < minT1) t = 0; if(maxT2 > maxT1) t = 0; if(w != 0) t = 0; if(t) cout << "TAK\n"; else 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 | #include <iostream> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int Z; cin >> Z; for(int z = 0; z < Z; z++){ int N; cin >> N; long long w = 0; int minT1 = 1000 * 1000 + 1, minT2 = 1000 * 1000 + 1; int maxT1 = 0, maxT2 = 0; for(int i = 0; i < N; i++){ int v, t1, t2; cin >> v >> t1 >> t2; w += (long long)v * t1; w -= (long long)v * t2; minT1 = min(minT1, t1); minT2 = min(minT2, t2); maxT1 = max(maxT1, t1); maxT2 = max(maxT2, t2); } bool t = 1; if(minT2 < minT1) t = 0; if(maxT2 > maxT1) t = 0; if(w != 0) t = 0; if(t) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |