結果

問題 No.433 ICPC国内予選の選抜ルールがこんな感じだったらうれしい
ユーザー jousenjousen
提出日時 2016-10-14 23:56:25
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 4,716 bytes
コンパイル時間 1,102 ms
コンパイル使用メモリ 108,288 KB
実行使用メモリ 40,936 KB
最終ジャッジ日時 2024-05-01 23:32:24
合計ジャッジ時間 19,002 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 39 ms
19,584 KB
testcase_31 AC 37 ms
19,712 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 38 ms
19,584 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 70 ms
24,960 KB
testcase_44 AC 64 ms
24,960 KB
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;


namespace tes
{
	class contest
	{
				
		
		static void Main(string[] args)
		{

			 var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = input[0];
            int k = input[1];
            var arr = new int[n][];

            var passed = new Dictionary<int, int>();
            var score = new Dictionary<int, int>();
            var memo = new Dictionary<Tuple<int, int, int>, int>();

            //memo the index of teams
            for (int i =0; i< n; i++)
            {
                arr[i] = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                int ac = arr[i][0];
                int penalty = arr[i][1];
                int univarsity = arr[i][2];

                memo[new Tuple<int, int, int>(ac, penalty, univarsity)] = i;
            }


            //Array.Sort(arr, (a, b) =>  b[0]-a[0]);
            arr = arr.OrderByDescending(a=>a[0]).ThenBy(c=>c[2]).ThenBy(b=>b[1]).ToArray();

            //memo the temporary No
            //var tmpNo = new Dictionary<int, int>();
            //for (int i = 0; i < n; i ++)
            //{
            //    int ac = arr[i][0];
            //    int penalty = arr[i][1];
            //    int univarsity = arr[i][2];

            //    memo[new Tuple<int, int, int>(ac, penalty, univarsity)] = i + 1;
            //}

            //count ans memo scores of all teams
            for (int i = 0; i < n; i++)
            {
                int ac = arr[i][0];
                int penalty = arr[i][1];
                int univarsity = arr[i][2];

              
                if (!score.Keys.Contains(ac))
                {
                    score[ac] = 1;
                }
                else score[ac] = score[ac] + 1;

            }


            var ans = new List<int>();


            for(int i =0; i<arr.Length-1; i++)
            {
                int ac = arr[i][0];
                int penalty = arr[i][1];
                int univarsity = arr[i][2];

                if (arr[i][0] == arr[i+1][0])
                {
                    if(arr[i][2] == arr[i+1][2])
                    {
                        ans.Add(memo[new Tuple<int, int, int>(ac, penalty, univarsity)]);

                        if (!passed.Keys.Contains(arr[i][2]))
                        {
                            passed[arr[i][2]] = 1;
                        }
                        else
                        {
                            passed[arr[i][2]] += 1;
                        }
                    }
                    else
                    {
                        if ((passed.Keys.Contains(arr[i][2]) && passed.Keys.Contains(arr[i+1][2]))&&
                            passed[arr[i][2]] < passed[arr[i+1][2]])
                        {
                            ans.Add(memo[new Tuple<int, int, int>(ac, penalty, univarsity)]);

                            if (!passed.Keys.Contains(arr[i][2]))
                            {
                                passed[arr[i][2]] = 1;
                            }
                            else
                            {
                                passed[arr[i][2]] += 1;
                            }
                        }
                        else
                        {
                            ac = arr[i+1][0];
                            penalty = arr[i+1][1];
                            univarsity = arr[i+1][2];

                            ans.Add(memo[new Tuple<int, int, int>(ac, penalty, univarsity)]);

                            if (!passed.Keys.Contains(arr[i+1][2]))
                            {
                                passed[arr[i+1][2]] = 1;
                            }
                            else
                            {
                                passed[arr[i+1][2]] += 1;
                            }
                        }
                    }
                }
                else
                {
                    ans.Add(memo[new Tuple<int, int, int>(ac, penalty, univarsity)]);

                    if (!passed.Keys.Contains(arr[i][2]))
                    {
                        passed[arr[i][2]] = 1;
                    }
                    else
                    {
                        passed[arr[i][2]] += 1;
                    }
                }

                if(i==arr.Length-1)
                {
                    ans.Add(memo[new Tuple<int, int, int>(ac, penalty, univarsity)]);
                }

                if (ans.Count == k) break;
            }

            ans.ForEach(Console.WriteLine);

        }
			
	}
}
0