UVa 12015 - Google is Feeling Lucky 解题报告

题目

题意:

给10个网站的名称和relate值,输出relate最高的,相同的按序输出

解法:

暴力……

Time:9ms
Memory:0KB
Length:490 B
#include<iostream>
#include <cstdio>
#define MAXN 1010
using namespace std;
char str[11][MAXN];
int rel[11];
int main()
{
    //freopen("input.txt","r",stdin);
    int ncase,best;
    scanf("%d",&ncase);
    for(int h=1;h<=ncase;++h)
    {
        best=-1;
        for(int i=0;i<10;++i)
            scanf("%s%d",str[i],&rel[i]),best=max(best,rel[i]);
        printf("Case #%d:\n",h);
        for(int i=0;i<10;++i)
            if(rel[i]==best)
                printf("%s\n",str[i]);
    }
}


你可能感兴趣的:(UVa 12015 - Google is Feeling Lucky 解题报告)