Solução: Impedido - SPOJ (Luis Bernardo)
From AdonaiMedrado.Pro.Br
Revision as of 12:25, 29 April 2009 by 200.17.147.2 (Talk) (New page: <code lang="c"> #include <stdio.h> #include <stdlib.h> char temImpedido(const int *,int, const int *, int); int main(){ int numAtacante,numDefensor,index,num; int *posicaoAtacantes;...)
#include <stdio.h> #include <stdlib.h> char temImpedido(const int *,int, const int *, int); int main(){ int numAtacante,numDefensor,index,num; int *posicaoAtacantes; int *posicaoDefensores; scanf("%d %d",&numAtacante,&numDefensor); while((numAtacante!=0)&&(numDefensor!=0)){ posicaoAtacantes = (int *) malloc(sizeof(int)*numAtacante); posicaoDefensores = (int *) malloc(sizeof(int)*numDefensor); for(index = 0; index<numAtacante ;index++){ scanf("%d",&num); posicaoAtacantes[index] = num; } for(index = 0; index<numDefensor ;index++){ scanf("%d",&num); posicaoDefensores[index] = num; } printf("%c\n",temImpedido(posicaoAtacantes, numAtacante, posicaoDefensores, numDefensor)); scanf("%d %d",&numAtacante,&numDefensor); } return 0; } char temImpedido(const int * atacante,int sizeA, const int * defensor,int sizeD){ int index,achou,index2; int numDefensor = 0; achou = 0; for(index = 0; index< sizeA;index++){ numDefensor = 0; for(index2 = 0; index2 < sizeD; index2++){ if(defensor[index2]<= atacante[index]) numDefensor++; } if(numDefensor < 2){ achou = 1; break; } } if(achou) return 'Y'; else return 'N'; }