## 2011/08/21

### Codeforces Beta Round #82(Div.2) report

My score is a little bad, however, I enjoy this contest very much!

I drank tea with friends, so I started this contest 0:15.
I made A, and got accepted at 0:27 with 2 submits.

I think B is not difficult, however, I had easy miss. I got accepted at 0:48 with 4 submits.

I read C and I don't want to solve it because I didn't  practice such problems enough. So, I read D and E, I decided to solve E.

I thought E is similar to least squares method, however it's not! I notice that point at 1:30, and I thought another method. But, time was over!

Now I think, E can be solved with downhill simplex method.

Problems are here.
Score:1104,Rank:541/1340,Rate:1504->1451.
I need more and more practice!
[A]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct card{
char suit;
char rank;
};

int win(struct card c1,struct card c2,char trump);
int num(char c);

int main(void){
struct card c[2];
char trump;
scanf("%c%*c",&trump);
scanf("%c%c %c%c%*c",&c[0].rank,&c[0].suit,&c[1].rank,&c[1].suit);
if(win(c[0],c[1],trump)) puts("YES");
else puts("NO");
return 0;
}

int win(struct card c1,struct card c2,char trump){
if(c1.suit==trump && c2.suit!=trump) return 1;
if(c2.suit==trump && c1.suit!=trump) return 0;
if(c1.suit!=c2.suit) return 0;
if(num(c1.rank)<num(c2.rank)) return 0;
else return 1;
}

int num(char c){
switch(c){
case 'T':
return 10;
break;
case 'J':
return 11;
break;
case 'Q':
return 12;
break;
case 'K':
return 13;
break;
case 'A':
return 14;
break;
default:
return c-'0';
}
}

[B]
#include<stdio.h>
#include<string.h>

typedef unsigned int u_int;

typedef struct{
u_int speed;
u_int ram;
u_int hdd;
u_int cost;
} laptop;

int main(void){
laptop coms[100],input;
u_int i,j,k,now=0,n,flg;
u_int min_num;

scanf("%u",&n);
while(n--){
scanf("%u %u %u %u",&input.speed,&input.ram,&input.hdd,&input.cost);
flg=1;
coms[now++]=input;
}

for(i=0;i<now;i++){
for(j=i+1;j<now;j++){
if(coms[i].speed<coms[j].speed && coms[i].ram<coms[j].ram && coms[i].hdd<coms[j].hdd) coms[i].cost=100000;
else if(coms[i].speed>coms[j].speed && coms[i].ram>coms[j].ram && coms[i].hdd>coms[j].hdd) coms[j].cost=100000;
}
}
min_num=0;
for(i=1;i<now;i++) if(coms[min_num].cost>coms[i].cost) min_num=i;
printf("%u\n",min_num+1);
return 0;
}