結果

問題 No.190 Dry Wet Moist
ユーザー 14番
提出日時 2016-05-02 10:58:59
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 246 ms / 2,000 ms
コード長 3,499 bytes
コンパイル時間 1,020 ms
コンパイル使用メモリ 112,012 KB
実行使用メモリ 50,352 KB
最終ジャッジ日時 2024-10-05 02:04:56
合計ジャッジ時間 5,791 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Text;
using System.Linq;
class Program
{
public void Proc()
{
Reader.IsDebug = false;
int inputCount = int.Parse(Reader.ReadLine());
List<int> minus = new List<int>();
List<int> plus = new List<int>();
List<int> zero = new List<int>();
int[] inpt = Reader.GetInt();
for(int i=0; i<inpt.Length; i++) {
if(inpt[i] > 0) {
plus.Add(inpt[i]);
} else if(inpt[i] < 0) {
minus.Add(inpt[i]);
} else
{
zero.Add(inpt[i]);
}
}
// dry
List<int> list = new List<int>(minus);
list.Sort();
list.Reverse();
List<int> target = new List<int>(zero);
target.AddRange(plus);
target.Sort();
List<int> amari = new List<int>();
int targetIndex = 0;
int dry = 0;
for(int i=0; i<list.Count && targetIndex < target.Count; i++) {
if(list[i] + target[targetIndex] < 0) {
dry++;
targetIndex++;
}
}
dry += (minus.Count - dry) / 2;
int wet = 0;
list = new List<int>(plus);
list.Sort();
target = new List<int>(minus);
target.AddRange(zero);
target.Sort();
target.Reverse();
targetIndex = 0;
for(int i=0; i<list.Count && targetIndex < target.Count; i++) {
if(list[i] + target[targetIndex] > 0) {
wet++;
targetIndex++;
}
}
wet += (plus.Count - wet) / 2;
int moist = zero.Count / 2;
int minusIndex = 0;
int plusIndex = 0;
minus.Sort();
plus.Sort();
plus.Reverse();
while (minusIndex < minus.Count && plusIndex < plus.Count)
{
if(minus[minusIndex] + plus[plusIndex] < 0) {
minusIndex++;
} else if(minus[minusIndex] + plus[plusIndex] > 0) {
plusIndex++;
} else
{
moist++;
minusIndex++;
plusIndex++;
}
}
Console.WriteLine(dry + " " + wet + " " + moist);
}
public class Reader
{
public static bool IsDebug = true;
private static String PlainInput = @"
4
-4 -3 -2 -1 1 2 3 4
";
private static System.IO.StringReader Sr = null;
public static string ReadLine()
{
if (IsDebug)
{
if (Sr == null)
{
Sr = new System.IO.StringReader(PlainInput.Trim());
}
return Sr.ReadLine();
}
else
{
return Console.ReadLine();
}
}
public static int[] GetInt(char delimiter = ' ', bool trim = false)
{
string inptStr = ReadLine();
if (trim)
{
inptStr = inptStr.Trim();
}
string[] inpt = inptStr.Split(delimiter);
int[] ret = new int[inpt.Length];
for (int i = 0; i < inpt.Length; i++)
{
ret[i] = int.Parse(inpt[i]);
}
return ret;
}
}
static void Main()
{
Program prg = new Program();
prg.Proc();
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0