#include <iostream> #include <vector> using namespace std; int main() { int ilosc_powtorzen; cin >> ilosc_powtorzen; while(ilosc_powtorzen--) { int przypadki_testowe; cin >> przypadki_testowe; vector <int> litry; vector <int> tem_P; vector <int> tem_K; int minTemP = 1000000, minTemK = 1000000; int maxTemP = 0, maxTemK = 0; while(przypadki_testowe--) { int masa = 0, TemP = 0, TemK = 0; cin >> masa; litry.push_back(masa); cin >> TemP; if(TemP < minTemP) minTemP = TemP; if(TemP > maxTemP) maxTemP = TemP; tem_P.push_back(TemP); cin >> TemK; if(TemK < minTemK) minTemK = TemK; if(TemK > maxTemK) maxTemK = TemK; tem_K.push_back(TemK); } /*for(int i = 0; i < litry.size(); i++) { cout << litry[i] << endl; cout << tem_P[i] << endl; cout << tem_K[i] << endl; }*/ int x = 0; for(int i = 0; i<litry.size(); i++) { x += (tem_K[i]-tem_P[i])*litry[i]; } if(x == 0) { if(minTemP <= minTemK && maxTemP >= maxTemK) cout << "TAK" << endl; else cout << "NIE" << endl; } else cout << "NIE" << endl; } 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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #include <iostream> #include <vector> using namespace std; int main() { int ilosc_powtorzen; cin >> ilosc_powtorzen; while(ilosc_powtorzen--) { int przypadki_testowe; cin >> przypadki_testowe; vector <int> litry; vector <int> tem_P; vector <int> tem_K; int minTemP = 1000000, minTemK = 1000000; int maxTemP = 0, maxTemK = 0; while(przypadki_testowe--) { int masa = 0, TemP = 0, TemK = 0; cin >> masa; litry.push_back(masa); cin >> TemP; if(TemP < minTemP) minTemP = TemP; if(TemP > maxTemP) maxTemP = TemP; tem_P.push_back(TemP); cin >> TemK; if(TemK < minTemK) minTemK = TemK; if(TemK > maxTemK) maxTemK = TemK; tem_K.push_back(TemK); } /*for(int i = 0; i < litry.size(); i++) { cout << litry[i] << endl; cout << tem_P[i] << endl; cout << tem_K[i] << endl; }*/ int x = 0; for(int i = 0; i<litry.size(); i++) { x += (tem_K[i]-tem_P[i])*litry[i]; } if(x == 0) { if(minTemP <= minTemK && maxTemP >= maxTemK) cout << "TAK" << endl; else cout << "NIE" << endl; } else cout << "NIE" << endl; } return 0; } |