#include <iostream> //Mirek Pietrzycki using namespace std; int t,n,l,a,b,minp=1000001, mink=1000001, maksp=0, maksk=0; long long sa,sb; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>t; for (int i=1; i<=t; ++i) { cin>>n; for (int j=1; j<=n; ++j) { cin>>l>>a>>b; sa=sa+l*a; sb=sb+l*b; if(a<minp)minp=a; if(b<mink)mink=b; if(a>maksp)maksp=a; if(b>maksk)maksk=b; } if(sa!=sb) cout<<"NIE\n"; else if(((maksp>=maksk)&&(minp<=mink))) cout<<"TAK\n"; else cout<<"NIE\n"; sa=0; sb=0; minp=1000001; mink=1000001; maksp=0; maksk=0; } 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 43 | #include <iostream> //Mirek Pietrzycki using namespace std; int t,n,l,a,b,minp=1000001, mink=1000001, maksp=0, maksk=0; long long sa,sb; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>t; for (int i=1; i<=t; ++i) { cin>>n; for (int j=1; j<=n; ++j) { cin>>l>>a>>b; sa=sa+l*a; sb=sb+l*b; if(a<minp)minp=a; if(b<mink)mink=b; if(a>maksp)maksp=a; if(b>maksk)maksk=b; } if(sa!=sb) cout<<"NIE\n"; else if(((maksp>=maksk)&&(minp<=mink))) cout<<"TAK\n"; else cout<<"NIE\n"; sa=0; sb=0; minp=1000001; mink=1000001; maksp=0; maksk=0; } return 0; } |