#include <stdio.h> int main() { int T,t,N,n; long long l,a,b,v,w,a_min,a_max,b_min,b_max; scanf("%d",&T); for (t = 0; t < T; t++) { v = w = 0; a_min = 1000001; a_max = 0; b_min = 1000001; b_max = 0; scanf("%d",&N); for (n = 0 ; n < N; n++) { scanf("%lld %lld %lld",&l,&a,&b); v += l*a; if (a < a_min) a_min = a; if (a > a_max) a_max = a; w += l*b; if (b < b_min) b_min = b; if (b > b_max) b_max = b; } if (b_min >= a_min && b_max <= a_max && v == w) printf("TAK\n"); else printf("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> int main() { int T,t,N,n; long long l,a,b,v,w,a_min,a_max,b_min,b_max; scanf("%d",&T); for (t = 0; t < T; t++) { v = w = 0; a_min = 1000001; a_max = 0; b_min = 1000001; b_max = 0; scanf("%d",&N); for (n = 0 ; n < N; n++) { scanf("%lld %lld %lld",&l,&a,&b); v += l*a; if (a < a_min) a_min = a; if (a > a_max) a_max = a; w += l*b; if (b < b_min) b_min = b; if (b > b_max) b_max = b; } if (b_min >= a_min && b_max <= a_max && v == w) printf("TAK\n"); else printf("NIE\n"); } return 0; } |