#include <iostream> using namespace std; int numberOfTests; int numberOfCompany; long * data1; long * data2; long * data3; long * data4; long getMaxValue(long in[], int size) { long max = in[0]; for (int i=0; i<size; i++) { if (in[i] > max) max = in[i]; } return max; } long getMinValue(long in[], int size) { long min = in[0]; for (int i=0; i<size; i++) { if (in[i] < min) min = in[i]; } return min; } void getAnswer() { long max[4]; int res = 0; max[0] = getMinValue(data1, numberOfCompany); max[1] = getMaxValue(data2, numberOfCompany); max[2] = getMinValue(data3, numberOfCompany); max[3] = getMaxValue(data4, numberOfCompany); for (int i=0; i<numberOfCompany; i++) { if ((data1[i]==max[0])&&(data2[i]==max[1])&&(data3[i]==max[2])&&(data4[i]==max[3])) { res = 1; i = numberOfCompany; } } if (res == 0) cout << "NIE\n"; else cout << "TAK\n"; } int main() { cin >> numberOfTests; for (int i=0; i<numberOfTests; i++) { cin >> numberOfCompany; data1 = new long[numberOfCompany]; data2 = new long[numberOfCompany]; data3 = new long[numberOfCompany]; data4 = new long[numberOfCompany]; for (int j=0; j<numberOfCompany; j++) { cin >> data1[j]; cin >> data2[j]; cin >> data3[j]; cin >> data4[j]; } getAnswer(); } 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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | #include <iostream> using namespace std; int numberOfTests; int numberOfCompany; long * data1; long * data2; long * data3; long * data4; long getMaxValue(long in[], int size) { long max = in[0]; for (int i=0; i<size; i++) { if (in[i] > max) max = in[i]; } return max; } long getMinValue(long in[], int size) { long min = in[0]; for (int i=0; i<size; i++) { if (in[i] < min) min = in[i]; } return min; } void getAnswer() { long max[4]; int res = 0; max[0] = getMinValue(data1, numberOfCompany); max[1] = getMaxValue(data2, numberOfCompany); max[2] = getMinValue(data3, numberOfCompany); max[3] = getMaxValue(data4, numberOfCompany); for (int i=0; i<numberOfCompany; i++) { if ((data1[i]==max[0])&&(data2[i]==max[1])&&(data3[i]==max[2])&&(data4[i]==max[3])) { res = 1; i = numberOfCompany; } } if (res == 0) cout << "NIE\n"; else cout << "TAK\n"; } int main() { cin >> numberOfTests; for (int i=0; i<numberOfTests; i++) { cin >> numberOfCompany; data1 = new long[numberOfCompany]; data2 = new long[numberOfCompany]; data3 = new long[numberOfCompany]; data4 = new long[numberOfCompany]; for (int j=0; j<numberOfCompany; j++) { cin >> data1[j]; cin >> data2[j]; cin >> data3[j]; cin >> data4[j]; } getAnswer(); } return 0; } |