-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeecrowd_1410.c
77 lines (60 loc) · 1.39 KB
/
beecrowd_1410.c
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
76
77
/*
Universidade de Brasília
Departamento de Ciência da Computação
CIC0004 - Algoritmos e Programação de Computadores
Vinicius R. P. Borges
Tópico: Vetores
Objetivo: Solução do problema beecrowd 1410 - He is Offside
https://judge.beecrowd.com/pt/problems/view/1410
Comandos no Terminal do Linux para compilar e executar o codigo-fonte:
gcc beecrowd_1410.c -o impedimento
./impedimento
*/
#include<stdio.h>
#define MAX_N 11
void ordena(int v[MAX_N], int n){
int i,j,aux;
for(i = 0; i < n-1; i++){
for(j = i+1; j < n; j++){
if(v[i] > v[j]){
aux = v[i];
v[i] = v[j];
v[j] = aux;
}
}
}
}
char solve(int a, int d){
int i,j,num;
int atacantes[MAX_N];
int defensores[MAX_N];
for(i = 0; i < a; i++){
scanf("%d",&atacantes[i]);
}
for(i = 0; i < d; i++){
scanf("%d",&defensores[i]);
}
ordena(defensores,d);
for(i = 0; i < a; i++){
num = 0;
j = 0;
while(j <= d && atacantes[i] >= defensores[j]){
j++;
}
if(j<2){
return 'Y';
}
}
return 'N';
}
int main(){
int a,d;
char ans;
scanf("%d %d",&a,&d);
while(a != 0 && d != 0){
ans = solve(a,d);
printf("%c\n",ans);
scanf("%d %d",&a,&d);
}
return 0;
}