#include <iostream>
using namespace std;
typedef long long BigInt;
int main()
{
BigInt t;
cin >> t;
for(BigInt i=0; i<t; ++i) {
BigInt totA = 0, totB = 0;
BigInt n, maxA = 0, maxB = 0;
cin >> n;
for(BigInt j=0; j<n; ++j) {
BigInt l, a, b;
cin >> l >> a >> b;
if(a>maxA) maxA = a;
if(b>maxB) maxB = b;
totA += a*l;
totB += b*l;
}
cout << ((totA == totB && maxA >= maxB) ? "TAK" : "NIE") << endl;
}
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 | #include <iostream> using namespace std; typedef long long BigInt; int main() { BigInt t; cin >> t; for(BigInt i=0; i<t; ++i) { BigInt totA = 0, totB = 0; BigInt n, maxA = 0, maxB = 0; cin >> n; for(BigInt j=0; j<n; ++j) { BigInt l, a, b; cin >> l >> a >> b; if(a>maxA) maxA = a; if(b>maxB) maxB = b; totA += a*l; totB += b*l; } cout << ((totA == totB && maxA >= maxB) ? "TAK" : "NIE") << endl; } return 0; } |
English