#include <bits/stdc++.h> using namespace std; int t,n,i,l,a,b,mina,maxa,minb,maxb; long long ra,rb; int main() { scanf("%d",&t); while (t--) { scanf("%d",&n); for (ra=rb=i=0; i<n; i++) { scanf("%d%d%d",&l,&a,&b); if (i==0) { mina=maxa=a; minb=maxb=b; } else { mina=min(mina,a); maxa=max(maxa,a); minb=min(minb,b); maxb=max(maxb,b); } ra+=1LL*l*a; rb+=1LL*l*b; } puts((ra==rb && mina<=minb && maxa>=maxb)?"TAK":"NIE"); } 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 | #include <bits/stdc++.h> using namespace std; int t,n,i,l,a,b,mina,maxa,minb,maxb; long long ra,rb; int main() { scanf("%d",&t); while (t--) { scanf("%d",&n); for (ra=rb=i=0; i<n; i++) { scanf("%d%d%d",&l,&a,&b); if (i==0) { mina=maxa=a; minb=maxb=b; } else { mina=min(mina,a); maxa=max(maxa,a); minb=min(minb,b); maxb=max(maxb,b); } ra+=1LL*l*a; rb+=1LL*l*b; } puts((ra==rb && mina<=minb && maxa>=maxb)?"TAK":"NIE"); } return 0; } |