結果

問題 No.297 カードの数式
ユーザー NoNo
提出日時 2015-11-07 00:22:15
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,358 bytes
コンパイル時間 4,873 ms
コンパイル使用メモリ 108,212 KB
実行使用メモリ 25,644 KB
最終ジャッジ日時 2023-10-11 14:41:18
合計ジャッジ時間 5,028 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 61 ms
23,748 KB
testcase_02 AC 61 ms
21,640 KB
testcase_03 WA -
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 62 ms
21,564 KB
testcase_08 AC 61 ms
19,640 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 62 ms
21,556 KB
testcase_13 WA -
testcase_14 AC 61 ms
21,644 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 RE -
testcase_19 WA -
testcase_20 WA -
testcase_21 RE -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.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());


     
        }
    }
}
0