|
| 1 | +#include <iostream> |
| 2 | +#include <algorithm> |
| 3 | + |
| 4 | +using namespace std; |
| 5 | + |
| 6 | +/* |
| 7 | + Problema: Ele Está Impedido! - 1410. |
| 8 | + |
| 9 | + Um jogador atacante está impedido se ele está mais próximo da linha do gol do oponente do que o penúltimo adversário. Um jogador não está impedido se |
| 10 | + |
| 11 | + - ele está na mesma linha que o penúltimo adversário ou |
| 12 | + - ele está na mesma linha que os dois últimos adversários. |
| 13 | +*/ |
| 14 | + |
| 15 | +void sortt(int *df, int n) { |
| 16 | + for (int i = 0; i < n; i++) { |
| 17 | + for (int j = i+1; j < n; j++) { |
| 18 | + if (df[i] > df[j]) { |
| 19 | + int aux = df[i]; |
| 20 | + df[i] = df[j]; |
| 21 | + df[j] = aux; |
| 22 | + } |
| 23 | + } |
| 24 | + } |
| 25 | +} |
| 26 | + |
| 27 | +int main() { |
| 28 | + |
| 29 | + int a, d, df[11], af[11], ok; |
| 30 | + |
| 31 | + while (cin >> a >> d && a && d) { |
| 32 | + ok = 1; |
| 33 | + // Reading Attackers |
| 34 | + for (int i = 0; i < a; i++) |
| 35 | + cin >> af[i]; |
| 36 | + |
| 37 | + // Reading Defenders |
| 38 | + for (int i = 0; i < d; i++) |
| 39 | + cin >> df[i]; |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | + sortt(df, d); |
| 44 | + |
| 45 | + // checking if there's no player in the wrong position |
| 46 | + for (int i = 0; i < a; i++) { |
| 47 | + // for each player, check if it's not in a correct position |
| 48 | + for (int j = 0; j < 2; j++) { |
| 49 | + if (af[i] < df[j]) { |
| 50 | + ok = 0; |
| 51 | + } |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + ok ? cout << "N" << endl : cout << "Y" << endl; |
| 56 | + |
| 57 | + } |
| 58 | + |
| 59 | + return 0; |
| 60 | +} |
0 commit comments