#include <iostream>
using namespace std;
int main()
{
int t;
cin >> t;
int n;
bool niedasie = false;
int maxtemp, mintemp;
for (int i = 0; i < t; i++)
{
cin >> n;
int* l = new int[n];
int* a = new int[n];
int* b = new int[n];
int cieplo = 0;
int cieplopotrzebne = 0;
int suma = 0;
maxtemp = 0;
mintemp = 1000001;
niedasie = false;
for (int j = 0; j < n; j++)
{
cin >> l[j] >> a[j] >> b[j];
if (a[j] > maxtemp)
maxtemp = a[j];
if (a[j] < mintemp)
mintemp = a[j];
suma += l[j];
cieplo += (l[j] * a[j]);
cieplopotrzebne += (l[j] * b[j]);
}
if (cieplopotrzebne != cieplo)
niedasie = true;
else
for (int j = 0; j < n; j++)
if (b[j] > maxtemp || b[j] < mintemp)
niedasie = true;
if(niedasie)
cout << "NIE" << endl;
else
cout << "TAK" << 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 | #include <iostream> using namespace std; int main() { int t; cin >> t; int n; bool niedasie = false; int maxtemp, mintemp; for (int i = 0; i < t; i++) { cin >> n; int* l = new int[n]; int* a = new int[n]; int* b = new int[n]; int cieplo = 0; int cieplopotrzebne = 0; int suma = 0; maxtemp = 0; mintemp = 1000001; niedasie = false; for (int j = 0; j < n; j++) { cin >> l[j] >> a[j] >> b[j]; if (a[j] > maxtemp) maxtemp = a[j]; if (a[j] < mintemp) mintemp = a[j]; suma += l[j]; cieplo += (l[j] * a[j]); cieplopotrzebne += (l[j] * b[j]); } if (cieplopotrzebne != cieplo) niedasie = true; else for (int j = 0; j < n; j++) if (b[j] > maxtemp || b[j] < mintemp) niedasie = true; if(niedasie) cout << "NIE" << endl; else cout << "TAK" << endl; } return 0; } |
English