#include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while(t--) { vector<pair<ll, ll>> A, B; int n; cin >> n; ll sum_l_times_a = 0, max_a = -1, min_a = 1000001; ll sum_l_times_b = 0, max_b = -1, min_b = 1000001; for(int i = 1; i <= n; i++) { ll l, a, b; cin >> l >> a >> b; A.push_back(make_pair(l, a)); B.push_back(make_pair(l, b)); sum_l_times_a += l * a; sum_l_times_b += l * b; max_a = max(a, max_a); max_b = max(b, max_b); min_a = min(a, min_a); min_b = min(b, min_b); } if(sum_l_times_a != sum_l_times_b || max_a < max_b || min_a > min_b) { cout << "NIE" << endl; } else { cout << "TAK" << 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 | #include <bits/stdc++.h> #define ll long long using namespace std; int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while(t--) { vector<pair<ll, ll>> A, B; int n; cin >> n; ll sum_l_times_a = 0, max_a = -1, min_a = 1000001; ll sum_l_times_b = 0, max_b = -1, min_b = 1000001; for(int i = 1; i <= n; i++) { ll l, a, b; cin >> l >> a >> b; A.push_back(make_pair(l, a)); B.push_back(make_pair(l, b)); sum_l_times_a += l * a; sum_l_times_b += l * b; max_a = max(a, max_a); max_b = max(b, max_b); min_a = min(a, min_a); min_b = min(b, min_b); } if(sum_l_times_a != sum_l_times_b || max_a < max_b || min_a > min_b) { cout << "NIE" << endl; } else { cout << "TAK" << endl; } } return 0; } |