結果
| 問題 |
No.190 Dry Wet Moist
|
| コンテスト | |
| ユーザー |
No
|
| 提出日時 | 2015-06-19 18:19:41 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 2,238 bytes |
| コンパイル時間 | 990 ms |
| コンパイル使用メモリ | 106,752 KB |
| 実行使用メモリ | 35,712 KB |
| 最終ジャッジ日時 | 2024-07-07 03:56:20 |
| 合計ジャッジ時間 | 4,156 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace foryuki
{
class Program
{
static int[] n;
static void Main(string[] args)
{
int N = int.Parse(Console.ReadLine());
var A = ConvertStringArrayToIntArray(Console.ReadLine().Split());
Array.Sort(A);
int i = 0;
int j = 2 * N - 1;
int dry = 0;
int wet = 0;
int moi = 0;
while (i < j)
{
if (A[i] + A[j] < 0)
{
dry++;
i++;
j--;
}
else
{
j--;
}
}
i = 0;
j = 2 * N - 1;
while (i < j)
{
if (A[i] + A[j] > 0)
{
wet++;
i++;
j--;
}
else
{
i++;
}
}
i = 0;
j = 2 * N - 1;
while (i < j)
{
if (A[i] + A[j] == 0)
{
moi++;
i++;
j--;
}
else
{
if (Math.Abs(A[i]) > Math.Abs(A[j]))
{
i++;
}
else
{
j--;
}
}
}
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;
}
}
}
No