夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

212 Easy Medium (div2)

わ〜

久々の昆布はネットつながんなくてさんざんw
さぁとりあえずコード貼りますか

Easy

public class YahtzeeScore {
    public int maxPoints(int[] toss) {
        int res;
        int[] yields = new int[6];
        for (int i = 0; i < 6; i++) yields[i] = 0;
        for (int i = 0; i < 5; i++)
        {
            yields[toss[i] - 1] += toss[i];
        }
        res = 0;
        for (int i = 0; i < 6; i++)
        {
            if (res < yields[i]) res = yields[i];
        }
        return res;
    }
}

Medium

public class WinningRecord {
    public int[] getBestAndWorst(string games) {
        int[] res = new int[2];
        double most = -1.0, least = 1000.0;
        int win = 0, lose = 0;
        for (int i = 0; i < games.Length; i++)
        {
            if (games[i] == 'W') win++;
            else lose++;
            if (i < 2) continue;
            double temp = (double)win * 100 / (double)(win + lose);
            if (most <= temp)
            {
                res[0] = i + 1;
                most = temp;
            }
            if (least >= temp)
            {
                res[1] = i + 1;
                least = temp;
            }
        }
        return res;
    }
}

反省

Mediumでキャストで引っかかったので気を付けていきたい。

広告を非表示にする