Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- #include <cstring>
- #include <string>
- #include <cctype>
- #include <stack>
- #include <queue>
- #include <list>
- #include <vector>
- #include <map>
- #include <set>
- #define N 1000000
- #define LL unsigned long long
- int princess[3];int prince[3]; int tomados[3];
- using namespace std;
- bool notomado(int a){
- for(int i=0;i<3;i++){
- if(a==tomados[i]){
- return false;
- }
- }
- return true;
- }
- bool test (int a){
- prince[2]=a;int posible=0;int cont;
- int cont1;
- cont1=0;tomados[cont1]=0;tomados[1]=0;tomados[2]=0;
- for (int i=0;i<3;i++){
- cont=0;
- for(int j=0;j<3;j++){
- if((princess[i]>prince[j]) && (notomado(prince[j]))){
- tomados[cont1]=prince[j];
- cont1++;
- cont++;break;
- }
- }
- if(cont>=1) posible++;
- }
- if (posible>=2){
- return false;
- }else{
- return true;
- }
- }
- bool verificar(int i){
- bool temp=true;
- for(int j=0;j<3;j++){
- if(princess[j]==i){
- temp=false;
- break;
- }
- }
- for(int j=0;j<2;j++){
- if(prince[j]==i){
- temp=false;
- break;
- }
- }
- return temp;
- }
- int main() {
- int a,b,c,d,e;
- int temp,posible,cont,min;bool noesta=false;
- bool verif=false;
- while (cin>>a>>b>>c>>d>>e){
- if(a==0 && b==0 && c==0 && d==0 && e==0) break;
- princess[0]=a;princess[1]=b;princess[2]=c;
- prince[0]=d;prince[1]=e;
- /*proceso de ordenamiento*/
- for(int i=1;i<2;i++){
- for(int j=0;j<2-i;j++){
- if (prince[j]>prince[j+1]){
- temp=prince[j];
- prince[j]=prince[j+1];
- prince[j+1]=temp;
- }
- }
- }
- for(int i=1;i<3;i++){
- for(int j=0;j<3-i;j++){
- if (princess[j]>princess[j+1]){
- temp=princess[j];
- princess[j]=princess[j+1];
- princess[j+1]=temp;
- }
- }
- }
- /*--------*/
- for(int i=1;i<53;i++){
- noesta=verificar(i);
- if (noesta){
- verif=test(i);
- if (verif){
- min=i;
- break;
- }
- }
- }
- if(!verif) printf("-1\n");
- else printf("%d\n",min);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement