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
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main() {
	long z; // Liczba zestawow
	scanf("%ld",&z);
	while (z>0) {
	    long n; //Liczba Bajtoniatek
	    long    l; // pojemnosc
	    long   tp; // t pocz
	    long   tk; // t konc
	    long long tpsum = 0;
	    long long tksum = 0;
	    long tpmin = 1000000;
	    long tpmax = 1;
	    long tkmin = 1000000;
	    long tkmax = 1;
        scanf("%ld", &n);
	    for (long i = 0; i < n; i++) {
	        scanf("%ld %ld %ld", &l, &tp, &tk);
	        //printf("%ld %ld %ld \n",l,tp,tk);
	        tpsum+=(l*tp);
	        tksum+=(l*tk);
	        if (tp > tpmax) tpmax = tp;
	        if (tp < tpmin) tpmin = tp;
	        if (tk > tkmax) tkmax = tk;
	        if (tk < tkmin) tkmin = tk;
	    }
        //printf("Suma %lld %lld\n",tpsum,tksum);
	    if (tpsum != tksum || tpmax < tkmax || tpmin > tkmin)
    	    printf("NIE\n");
    	else
    	    printf("TAK\n");
	    z--;
	}
    return 0;
}