結果
| 問題 |
No.297 カードの数式
|
| コンテスト | |
| ユーザー |
No
|
| 提出日時 | 2015-11-07 00:22:15 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,358 bytes |
| コンパイル時間 | 1,123 ms |
| コンパイル使用メモリ | 114,920 KB |
| 実行使用メモリ | 27,540 KB |
| 最終ジャッジ日時 | 2024-09-13 13:21:52 |
| 合計ジャッジ時間 | 2,683 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 4 WA * 15 RE * 4 |
コンパイルメッセージ
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 Yuki
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
string[] s = Console.ReadLine().Split();
int p = s.Where(x => x.Equals("+")).Count();
int m = s.Where(x => x.Equals("-")).Count();
int k = n - p - m;
int[] a = new int[k];
int b;
int j = 0;
for (int i = 0; i < n; i++)
{
if (int.TryParse(s[i], out b) || s[i] == "0")
{
a[j] = b;
j++;
}
}
Array.Sort(a);
//max
string st = "";
for (int i = a.Length - 1; i > m + p - 1; i--)
{
st += a[i].ToString();
}
int max = int.Parse(st);
for (int i = 0; i < p + m; i++)
{
if (i < m)
{
max = max - a[i];
}
else
{
max = max + a[i];
}
}
Console.WriteLine(max + " " + "-" + max.ToString());
}
}
}
No