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 43 44 45 46 47 48 #include using namespace std; int main() { int t; cin >> t; for(int i = 0; i < t; ++i) { int numberOfChildren; cin >> numberOfChildren; long long actualSum = 0; long long wantedSum = 0; long long theColdestActual = 1000001; long long theColdestWanted = 1000001; long long theHotestActual = -1; long long theHotestWanted = -1; long long l, a, b; long long difference = 0; for(int j = 0; j < numberOfChildren; ++j) { cin >> l >> a >> b; actualSum += l*a; wantedSum += l*b; difference += (b-a)*l; if(theColdestActual > a) theColdestActual = a; if(theColdestWanted > b) theColdestWanted = b; if(theHotestActual < a) theHotestActual = a; if(theHotestWanted < b) theHotestWanted = b; } //cout << actualSum << endl << theColdestActual << " " // << theColdestWanted << endl << theHotestActual << " " // << theHotestWanted << endl << difference << endl; if(actualSum != wantedSum || theColdestWanted < theColdestActual || theHotestWanted > theHotestActual || difference != 0) { cout << "NIE\n"; continue; } cout << "TAK\n"; } }