#include <cstdio> #include <iostream> #include <algorithm> using namespace std; const int MAX = 1000000+1; string c; long long int a; long long int b; int main(){ int t = 0; cin >> t; while(t>0){ int n = 0; long long int l = 0; cin >> n; long long int sum_a = 0; long long int sum_b = 0; long long int max_a = 0; long long int min_a = MAX; long long int max_b = 0; long long int min_b = MAX; for(int i=0; i<n; ++i){ cin >> l; cin >> a; cin >> b; if(a < min_a){ min_a = a; } if(a > max_a){ max_a = a; } if(b < min_b){ min_b = b; } if(b > max_b){ max_b = b; } sum_a+=a*l; sum_b+=b*l; } if(sum_a != sum_b){ cout << "NIE" << "\n"; }else{ if(min_b < min_a){ cout << "NIE" << "\n"; }else{ if(max_b > max_a){ cout << "NIE" << "\n"; }else{ cout << "TAK" << "\n"; } } } t--; } 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | #include <cstdio> #include <iostream> #include <algorithm> using namespace std; const int MAX = 1000000+1; string c; long long int a; long long int b; int main(){ int t = 0; cin >> t; while(t>0){ int n = 0; long long int l = 0; cin >> n; long long int sum_a = 0; long long int sum_b = 0; long long int max_a = 0; long long int min_a = MAX; long long int max_b = 0; long long int min_b = MAX; for(int i=0; i<n; ++i){ cin >> l; cin >> a; cin >> b; if(a < min_a){ min_a = a; } if(a > max_a){ max_a = a; } if(b < min_b){ min_b = b; } if(b > max_b){ max_b = b; } sum_a+=a*l; sum_b+=b*l; } if(sum_a != sum_b){ cout << "NIE" << "\n"; }else{ if(min_b < min_a){ cout << "NIE" << "\n"; }else{ if(max_b > max_a){ cout << "NIE" << "\n"; }else{ cout << "TAK" << "\n"; } } } t--; } return 0; } |