#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-9;
const int MAXN = 1e5+4;
int t, n;
long long l[MAXN], a[MAXN], b[MAXN];
int main()
{
scanf("%d", &t);
while(t--) {
scanf("%d", &n);
for(int i = 1; i <= n; i++)
scanf("%lld%lld%lld", &l[i], &a[i], &b[i]);
long long res1 = 0, res2 = 0;
for(int i = 1; i <= n; i++)
res1 += l[i] * a[i], res2 += l[i] * b[i];
if(res1 != res2) {
printf("NIE\n");
continue;
}
sort(a+1, a+n+1);
sort(b+1, b+n+1);
if(a[1] <= b[1] && b[n] <= a[n])
printf("TAK\n");
else
printf("NIE\n");
}
}
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 <bits/stdc++.h> using namespace std; const double eps = 1e-9; const int MAXN = 1e5+4; int t, n; long long l[MAXN], a[MAXN], b[MAXN]; int main() { scanf("%d", &t); while(t--) { scanf("%d", &n); for(int i = 1; i <= n; i++) scanf("%lld%lld%lld", &l[i], &a[i], &b[i]); long long res1 = 0, res2 = 0; for(int i = 1; i <= n; i++) res1 += l[i] * a[i], res2 += l[i] * b[i]; if(res1 != res2) { printf("NIE\n"); continue; } sort(a+1, a+n+1); sort(b+1, b+n+1); if(a[1] <= b[1] && b[n] <= a[n]) printf("TAK\n"); else printf("NIE\n"); } } |
English