結果
問題 |
No.190 Dry Wet Moist
|
ユーザー |
![]() |
提出日時 | 2015-06-17 16:15:07 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,269 bytes |
コンパイル時間 | 2,548 ms |
コンパイル使用メモリ | 112,032 KB |
実行使用メモリ | 53,292 KB |
最終ジャッジ日時 | 2024-07-07 03:32:26 |
合計ジャッジ時間 | 13,981 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 WA * 5 TLE * 2 -- * 13 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace foryuki { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); var A = ConvertStringArrayToIntArray(Console.ReadLine().Split()); var d = A.Where(x => x < 0).OrderBy(x => x).ToArray(); var w = A.Where(x => x > 0).OrderByDescending(x => x).ToArray(); var m = A.Where(x => x == 0).ToArray(); int cnt = 0; int k = 0; for (int i = 0; i < d.Length; i++) { for (int j = k; j < w.Length; j++) { if (d[i] + w[j] < 0) { cnt++; k = j + 1; break; } } } if (cnt < d.Length) { if (d.Length - cnt >= m.Length) { cnt = cnt + m.Length; } else { cnt = d.Length; } } if (cnt < d.Length) { cnt = cnt + (d.Length - cnt) / 2; } int dry = cnt; //---------------------------------------------------- cnt = 0; k = 0; for (int i = 0; i < w.Length; i++) { for (int j = k; j < d.Length; j++) { if (w[i] + d[j] > 0) { cnt++; k = j + 1; break; } } } if (cnt < w.Length) { if (w.Length - cnt >= m.Length) { cnt = cnt + m.Length; } else { cnt = w.Length; } } if (cnt < w.Length) { cnt = cnt + (w.Length - cnt) / 2; } int wet = cnt; //-------------------------------------------------- cnt = 0; k = 0; for (int i = 0; i < d.Length; i++) { for (int j = k; j < w.Length; j++) { if (d[i] + w[j] == 0) { cnt++; k = j + 1; break; } } } int moi = cnt + m.Length; Console.WriteLine("{0} {1} {2}",dry,wet,moi); } //------------------------------------------------------------- static int[] ConvertStringArrayToIntArray(string[] array) { return Array.ConvertAll(array, str => int.Parse(str)); } static List<int> ConvertStringArrayToIntList(string[] str) { var list = new List<int>(); foreach (var c in str) { list.Add(int.Parse(c)); } return list; } } }