#include <bits/stdc++.h> using namespace std; int a,b,mina,minb,maxb,maxa; long long wyna,wynb; int x,n,z; int main(){ ios_base::sync_with_stdio(0); cin>>z; for(int i=1; i<=z; i++){ cin>>n>>x>>a>>b; mina=a; maxa=a; minb=b; maxb=b; long long iloscmia=x; long long iloscmib=x; long long iloscmxa=x; long long iloscmxb=x; wyna=0; wynb=0; wyna=wyna+a*x; wynb=wynb+b*x; for(int j=2; j<=n; j++){ cin>>x>>a>>b; wyna=wyna+a*x; wynb=wynb+b*x; if(mina!=min(mina,a)){ mina=a; iloscmia=x; } else if(a==mina) iloscmia+=x; if(maxa!=max(maxa,a)){ maxa=a; iloscmxa=x; } else if(a==maxa) iloscmxa+=x; if(minb!=min(minb,b)){ minb=b; iloscmib=x; } else if(b==minb) iloscmib+=x; if(maxb!=max(maxb,b)){ maxb=b; iloscmxb=x; } else if(b==maxb) iloscmxb+=x; } if( (maxb<maxa || (maxb==maxa && iloscmxb<=iloscmxa )) && (minb>mina || ( iloscmia>=iloscmib && minb==mina)) && wyna==wynb ){ cout<<"TAK"<<endl; } else cout<<"NIE"<<endl; } }
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 49 50 51 52 53 54 55 56 57 | #include <bits/stdc++.h> using namespace std; int a,b,mina,minb,maxb,maxa; long long wyna,wynb; int x,n,z; int main(){ ios_base::sync_with_stdio(0); cin>>z; for(int i=1; i<=z; i++){ cin>>n>>x>>a>>b; mina=a; maxa=a; minb=b; maxb=b; long long iloscmia=x; long long iloscmib=x; long long iloscmxa=x; long long iloscmxb=x; wyna=0; wynb=0; wyna=wyna+a*x; wynb=wynb+b*x; for(int j=2; j<=n; j++){ cin>>x>>a>>b; wyna=wyna+a*x; wynb=wynb+b*x; if(mina!=min(mina,a)){ mina=a; iloscmia=x; } else if(a==mina) iloscmia+=x; if(maxa!=max(maxa,a)){ maxa=a; iloscmxa=x; } else if(a==maxa) iloscmxa+=x; if(minb!=min(minb,b)){ minb=b; iloscmib=x; } else if(b==minb) iloscmib+=x; if(maxb!=max(maxb,b)){ maxb=b; iloscmxb=x; } else if(b==maxb) iloscmxb+=x; } if( (maxb<maxa || (maxb==maxa && iloscmxb<=iloscmxa )) && (minb>mina || ( iloscmia>=iloscmib && minb==mina)) && wyna==wynb ){ cout<<"TAK"<<endl; } else cout<<"NIE"<<endl; } } |