Skip to content

Instantly share code, notes, and snippets.

@rainbow23
Created May 29, 2017 20:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rainbow23/4774558503803ad60bae3f352e6ce64e to your computer and use it in GitHub Desktop.
Save rainbow23/4774558503803ad60bae3f352e6ce64e to your computer and use it in GitHub Desktop.
C036:[もし女コラボ問題]犬ぞりトーナメント
using System;
public class Hello{
public static void Main(){
// 自分の得意な言語で
// Let's チャレンジ!!
String[] gameMatchNum = new String[2];
for(int ci =0; ci < 2; ci++)
{
gameMatchNum[ci] = System.Console.ReadLine();
//System.Console.WriteLine("{0}", gameMatchNum[ci]);
}
var game1AllTimer = System.Console.ReadLine();
//System.Console.WriteLine("{0}", game1AllTimer);
// [index, time]
int[,] matchindex = new int[4, 2];
int count = 0;
for(int ci =0; ci < 2; ci++)
{
String[] matchnum = gameMatchNum[ci].Split(' ');
for(int mi = 0; mi < matchnum.Length; mi++, count++)
{
int num = Int32.Parse(matchnum[mi]);
matchindex[count, 0] = num;
// System.Console.WriteLine("m index: {0}", matchindex[count, 0]);
}
}
// game1 index time string to int index
String[] allTime = game1AllTimer.Split(' ');
for(int m1 = 0; m1 < allTime.Length; m1++)
{
int time = Int32.Parse(allTime[m1]);
//System.Console.WriteLine("time: {0}",time);
for(int m2=0; m2<4; m2++)
{
int timeIndex = m1 + 1;
if(matchindex[m2, 0] == timeIndex){
matchindex[m2, 1] = time;
//System.Console.WriteLine("match index:{0} time:{1}", matchindex[m2, 0], matchindex[m2, 1]);
}
}
}
//for(int ci=0; ci<4; ci++)
//System.Console.WriteLine("entry: {0} time:{1}",matchindex[ci, 0], matchindex[ci, 1]);
for(int mi =0; mi<4; mi+=2)//first round //match1 and match2
{
//一回戦でtimeが短い方がindex少ない方に書き換える
if(matchindex[mi, 1] > matchindex[mi+1, 1])
{
matchindex[mi, 0] = matchindex[mi+1, 0];
matchindex[mi, 1] = matchindex[mi+1, 1];
//System.Console.WriteLine("entry: {0} time:{1}",matchindex[mi, 0], matchindex[mi, 1]);
}
}
//final round timeが短い方がprint
if(matchindex[0, 1] > matchindex[2, 1]){
System.Console.WriteLine("{0}",matchindex[2, 0]);
System.Console.WriteLine("{0}",matchindex[0, 0]);
//System.Console.WriteLine("{0}",matchindex[2, 1]);
//System.Console.WriteLine("{0}",matchindex[0, 1]);
}else{
System.Console.WriteLine("{0}",matchindex[0, 0]);
System.Console.WriteLine("{0}",matchindex[2, 0]);
//System.Console.WriteLine("{0}",matchindex[2, 1]);
//System.Console.WriteLine("{0}",matchindex[0, 1]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment