#include <bits/stdc++.h> using namespace std; #define f first #define s second int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long w1,w2,t,n,l,a,b,i,mina,maxa,minb,maxb; cin >> t; for(; t>=1; t--) { w1=0; w2=0; mina=0; minb=0; maxa=0; maxb=0; cin >> n; for(i=1; i<=n; i++) { cin >> l >> a >> b; mina=min(mina,a); maxa=max(maxa,a); minb=min(minb,b); maxb=max(maxb,b); w1+=l*a; w2+=l*b; } if(mina>minb || maxa<maxb) cout << "NIE\n"; else if(w1==w2) cout << "TAK\n"; else cout << "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 33 34 35 36 37 38 39 40 41 42 | #include <bits/stdc++.h> using namespace std; #define f first #define s second int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long w1,w2,t,n,l,a,b,i,mina,maxa,minb,maxb; cin >> t; for(; t>=1; t--) { w1=0; w2=0; mina=0; minb=0; maxa=0; maxb=0; cin >> n; for(i=1; i<=n; i++) { cin >> l >> a >> b; mina=min(mina,a); maxa=max(maxa,a); minb=min(minb,b); maxb=max(maxb,b); w1+=l*a; w2+=l*b; } if(mina>minb || maxa<maxb) cout << "NIE\n"; else if(w1==w2) cout << "TAK\n"; else cout << "NIE\n"; } return 0; } |