#include <stdio.h> #include <vector> #include <algorithm> int main() { int t; scanf("%d",&t); for(int i=0;i<t;++i) { int n; scanf("%d",&n); long long int s0=0; int amin=1000000,amax=1,bmin=1000000,bmax=1; long long int s1=0; for(int j=0;j<n;++j) { long long int l,a,b; scanf("%lld %lld %lld",&l,&a,&b); if(amin>a)amin=a; if(amax<a)amax=a; if(bmin>b)bmin=b; if(bmax<b)amax=b; s0+=l*a; s1+=l*b; } printf((s0==s1&&amin<=bmin&&bmax<=amax)?"TAK\n":"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 | #include <stdio.h> #include <vector> #include <algorithm> int main() { int t; scanf("%d",&t); for(int i=0;i<t;++i) { int n; scanf("%d",&n); long long int s0=0; int amin=1000000,amax=1,bmin=1000000,bmax=1; long long int s1=0; for(int j=0;j<n;++j) { long long int l,a,b; scanf("%lld %lld %lld",&l,&a,&b); if(amin>a)amin=a; if(amax<a)amax=a; if(bmin>b)bmin=b; if(bmax<b)amax=b; s0+=l*a; s1+=l*b; } printf((s0==s1&&amin<=bmin&&bmax<=amax)?"TAK\n":"NIE\n"); } return 0; } |