結果

問題 No.190 Dry Wet Moist
ユーザー syoken_desuka
提出日時 2015-04-22 01:20:05
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 6,822 bytes
コンパイル時間 945 ms
コンパイル使用メモリ 117,808 KB
実行使用メモリ 43,140 KB
最終ジャッジ日時 2024-07-04 23:29:27
合計ジャッジ時間 3,951 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 #
プレゼンテーションモードにする

#region ZIPPER
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using sc = Scanner;
using System.Numerics;
//using Geometry;
//using gl = Geometry.GeometryLibrary;
class Program
{
static void Main(string[] args)
{
Solver solver = new Solver();
solver.Solve();
#if DEBUG
System.Console.WriteLine("");
System.Console.ReadKey();
#endif
}
}
/// <summary>
///
/// </summary>
#endregion ZIPPER
public class Solver
{
#region IGNORE_ME
public Solver()
{
// 
}
#endregion IGNORE_ME
public int MOD = 1000000007;//10^9 + 7
public void Solve()
{
int n = sc.NextInt();
int[] a = sc.NextIntArray();
Array.Sort(a);
int i = 0;
int j = a.Length - 1;
int dry = 0;
int moist = 0;
int wet = 0;
//moist
while (i < j)
{
if (a[i] + a[j] < 0)
{
dry++;
i++;
j--;
}
else
{
j--;
}
}
//wet
i = 0;
j = a.Length - 1;
while (i < j)
{
if (a[i] + a[j] > 0)
{
wet++;
i++;
j--;
}
else
{
i++;
}
}
i = 0;
j = a.Length - 1;
while (i < j)
{
if (a[i] + a[j] == 0 )
{
moist++;
i++;
j--;
}
else
{
if (a[i] + a[j] > 0)//wet more dry
{
j--;
}
else // more wet
{
i++;
}
}
}
Console.WriteLine("{0} {1} {2}",dry,wet,moist);
#if DEBUG
Console.WriteLine("");//local check
#endif
}
}
public static class Scanner
{
public static string NextString()
{
string tmp = "";
while (true)
{
int readData;
string data;
readData = Console.Read();
if (readData == -1) //EOF
{
break;
}
data = char.ConvertFromUtf32(readData);
if (data == " " || data == "\n")
{
break;
}
tmp += data;
}
return tmp;
}
public static int NextInt()
{
string tmp = "";
while (true)
{
int readData;
string data;
readData = Console.Read();
if (readData == -1) //EOF
{
break;
}
data = char.ConvertFromUtf32(readData);
if (data == " " || data == "\n")
{
break;
}
tmp += data;
}
return int.Parse(tmp);
}
public static long NextLong()
{
string tmp = "";
while (true)
{
int readData;
string data;
readData = Console.Read();
if (readData == -1) //EOF
{
break;
}
data = char.ConvertFromUtf32(readData);
if (data == " " || data == "\n")
{
break;
}
tmp += data;
}
return long.Parse(tmp);
}
public static double NextDouble()
{
string tmp = "";
while (true)
{
int readData;
string data;
readData = Console.Read();
if (readData == -1) //EOF
{
break;
}
data = char.ConvertFromUtf32(readData);
if (data == " " || data == "\n")
{
break;
}
tmp += data;
}
return double.Parse(tmp);
}
public static string[] NextStrArray()
{
return Console.ReadLine().Split(' ');
}
public static int[] NextIntArray()
{
string[] s = NextStrArray();
int[] a = new int[s.Length];
for (int i = 0; i < a.Length; i++)
{
a[i] = int.Parse(s[i]);
}
return a;
}
public static long[] NextLongArray()
{
string[] s = NextStrArray();
long[] a = new long[s.Length];
for (int i = 0; i < a.Length; i++)
{
a[i] = long.Parse(s[i]);
}
return a;
}
public static double[] NextDoubleArray()
{
string[] s = NextStrArray();
double[] a = new double[s.Length];
for (int i = 0; i < a.Length; i++)
{
a[i] = double.Parse(s[i]);
}
return a;
}
}
/// <summary>
///
///
/// </summary>
public static class CharInterpreter
{
/// <summary>
///
/// </summary>
private static Dictionary<char, int> MapToInt = new Dictionary<char, int>();
/// <summary>
///
/// </summary>
/// <param name="c">char</param>
/// <param name="i"></param>
public static void AddCorrespondence(char c,int i)
{
MapToInt.Add(c,i);
}
/// <summary>
///
///
/// </summary>
/// <returns></returns>
public static int Inquiry(char c)
{
int ret = 0;
MapToInt.TryGetValue(c, out ret);
return ret;
}
/// <summary>
/// int[,]
///
/// </summary>
/// <param name="field"></param>
/// <returns> int[ field.length , field[0].length] </returns>
public static int[,] GenerateSquareField(string[] field)
{
int[,] ret = new int[field.Length, field[0].Length];
for (int i = 0; i < field.Length; i++)
{
for (int j = 0; j < field[0].Length; j++)
{
MapToInt.TryGetValue(field[i][j], out ret[i, j]);
}
}
return ret;
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0