結果
問題 |
No.914 Omiyage
|
ユーザー |
![]() |
提出日時 | 2023-06-09 11:47:02 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,370 bytes |
コンパイル時間 | 2,562 ms |
コンパイル使用メモリ | 113,404 KB |
実行使用メモリ | 27,656 KB |
最終ジャッジ日時 | 2024-12-31 20:47:53 |
合計ジャッジ時間 | 2,513 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 5 WA * 12 RE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; using System.Collections.Generic; namespace yukicoder { class pg { static void Main(string[] args) { var line = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).ToList(); int N = line[0]; int M = line[1]; int K = line[2]; var nations = new List<int>[N]; var takeGiftList = Enumerable.Repeat<int>(1,N).ToArray(); int iniTotal = 0; for(int i = 0;i < N;i++) { var gifts = Console.ReadLine().Split(' ').Select(c => int.Parse(c)).OrderBy(c => c).ToList(); nations[i] = gifts; iniTotal += gifts[0]; } if(iniTotal > K)Console.WriteLine(-1); int total = iniTotal; int oldTotal; while(true) { int minMoney = int.MaxValue; int minNation = -1; bool SerchFlag = false; for(int q = 0;q < N;q++) { if(takeGiftList[q] >= N)continue; int a = nations[q][takeGiftList[q]]; if(a < minMoney) { SerchFlag = true; minNation = q; minMoney = a; } } if(!SerchFlag) { Console.WriteLine(K - total); return; } oldTotal = total; int b = takeGiftList[minNation]; int c = nations[minNation][b] - nations[minNation][b - 1]; if(total + c > K) { Console.WriteLine(K - total); return; } total += c; } } } }