結果
問題 |
No.5001 排他的論理和でランニング
|
ユーザー |
![]() |
提出日時 | 2018-03-16 22:35:32 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 124 ms / 1,500 ms |
コード長 | 1,982 bytes |
コンパイル時間 | 850 ms |
実行使用メモリ | 43,620 KB |
スコア | 35,088,705 |
最終ジャッジ日時 | 2020-03-12 19:23:54 |
ジャッジサーバーID (参考情報) |
judge8 / |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 50 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.5.0-beta1-19606-04 (d2bd58c6) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.IO; using System.Text; class Program { static StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false }; static Scan sc = new Scan(); static void Main() { int n, m; sc.Multi(out n, out m); var a = sc.IntArr; Array.Sort(a); var ans = new int[m]; for (int i = 0; i < m - 1; i++) ans[i] = a[i]; ans[m - 1] = a[n - 1]; Prt(ans); sw.Flush(); } static void Prt(string a) => sw.WriteLine(a); static void Prt<T>(IEnumerable<T> a) => Prt(string.Join(" ", a)); static void Prt(params object[] a) => Prt(string.Join(" ", a)); } class Scan { public int Int => int.Parse(Str); public long Long => long.Parse(Str); public double Double => double.Parse(Str); public string Str => Console.ReadLine().Trim(); public int[] IntArr => StrArr.Select(int.Parse).ToArray(); public long[] LongArr => StrArr.Select(long.Parse).ToArray(); public double[] DoubleArr => StrArr.Select(double.Parse).ToArray(); public string[] StrArr => Str.Split(new []{' '}, System.StringSplitOptions.RemoveEmptyEntries); bool eq<T, U>() => typeof(T).Equals(typeof(U)); T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T)); T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s)) : eq<T, long>() ? ct<T, long>(long.Parse(s)) : eq<T, double>() ? ct<T, double>(double.Parse(s)) : eq<T, char>() ? ct<T, char>(s[0]) : ct<T, string>(s); public void Multi<T>(out T a) => a = cv<T>(Str); public void Multi<T, U>(out T a, out U b) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); } public void Multi<T, U, V>(out T a, out U b, out V c) { var ar = StrArr; a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); } }