#include<bits/stdc++.h> using namespace std; int dol1=10000000, dol2=10000000, ma1=0, ma2, a, k ,n, t1, t2; long long gor2, gor1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int t=1; t<=n; t++) { cin>>k; for(int i=1; i<=k;i++) { cin>>a>>t1>>t2; ma1=max(t1, ma1); ma2=max(t2, ma2); dol1=min(t1, dol1); dol2=min(t2, dol2); gor1+=(long long)t1*(long long)a; gor2+=(long long)t2*(long long)a; } if(gor1==gor2 && dol1<=dol2 && ma1>=ma2) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; gor1=0; gor2=0; dol1=10000000; dol2=1000000000; ma1=0; ma2=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 | #include<bits/stdc++.h> using namespace std; int dol1=10000000, dol2=10000000, ma1=0, ma2, a, k ,n, t1, t2; long long gor2, gor1; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; for(int t=1; t<=n; t++) { cin>>k; for(int i=1; i<=k;i++) { cin>>a>>t1>>t2; ma1=max(t1, ma1); ma2=max(t2, ma2); dol1=min(t1, dol1); dol2=min(t2, dol2); gor1+=(long long)t1*(long long)a; gor2+=(long long)t2*(long long)a; } if(gor1==gor2 && dol1<=dol2 && ma1>=ma2) cout<<"TAK"<<endl; else cout<<"NIE"<<endl; gor1=0; gor2=0; dol1=10000000; dol2=1000000000; ma1=0; ma2=0; } return 0; } |