#include<bits/stdc++.h> using namespace std; typedef long long ll; main () { ios_base::sync_with_stdio(false); int Z; cin>>Z; while(Z--) { ll m, t1, t2, max1, max2, min1, min2; int n; cin>>n; cin>>m; cin>>t1>>t2; t1=t1*m; t2=t2*m; max1=t1; max2=t2; min1=t1; min2=t2; for (int i=1; i<n; i++) { ll l, a, b; cin>>l>>a>>b; if (a!=b) { max1=max(max1, a); max2=max(max2, b); min1=min(min1, a); min2=min(min2, b); t1=t1+a*l; t2=t2+b*l; } } if (t1==t2 && max1>=max2 && min1<=min2) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } }
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<bits/stdc++.h> using namespace std; typedef long long ll; main () { ios_base::sync_with_stdio(false); int Z; cin>>Z; while(Z--) { ll m, t1, t2, max1, max2, min1, min2; int n; cin>>n; cin>>m; cin>>t1>>t2; t1=t1*m; t2=t2*m; max1=t1; max2=t2; min1=t1; min2=t2; for (int i=1; i<n; i++) { ll l, a, b; cin>>l>>a>>b; if (a!=b) { max1=max(max1, a); max2=max(max2, b); min1=min(min1, a); min2=min(min2, b); t1=t1+a*l; t2=t2+b*l; } } if (t1==t2 && max1>=max2 && min1<=min2) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } } |