結果

問題 No.297 カードの数式
ユーザー r_nokor_noko
提出日時 2015-11-08 18:55:25
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,489 bytes
コンパイル時間 2,995 ms
コンパイル使用メモリ 109,360 KB
実行使用メモリ 29,432 KB
最終ジャッジ日時 2023-10-11 15:20:41
合計ジャッジ時間 7,091 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
27,164 KB
testcase_01 AC 109 ms
25,224 KB
testcase_02 AC 108 ms
25,120 KB
testcase_03 WA -
testcase_04 AC 111 ms
25,524 KB
testcase_05 AC 105 ms
25,260 KB
testcase_06 WA -
testcase_07 AC 108 ms
25,060 KB
testcase_08 AC 107 ms
27,164 KB
testcase_09 AC 104 ms
23,016 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 108 ms
27,292 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 109 ms
25,296 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

namespace contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            var p = input.Where(x => x == "+").Select(x => x);
            var m = input.Where(x => x == "-").Select(x => x);
            var pm = p.Concat(m);
            var n = input.Where(x => !pm.Contains(x)).OrderByDescending(x => x).Select(x => x);
            var nn = input.Where(x => !pm.Contains(x)).OrderBy(x => x).Select(x => x);

            var g = n.Take(n.Count() - pm.Count()).Select(x => x);
            double b = 0;
            double a = 0;

            for (int i = 0; i < g.Count(); i++)
                a += double.Parse(g.ToArray()[i]) * Math.Pow(10, g.Count() - 1 - i);
            b = a;

            int cnt = g.Count();
            int ncnt = cnt;

            for (int i = 0; i < p.Count(); i++)
            {
                a += double.Parse(n.Skip(cnt++).Select(x => x).ToArray()[0]);
                b += double.Parse(nn.Skip(ncnt++).Select(x => x).ToArray()[0]);

            }

            for (int i = 0; i < m.Count(); i++)
            {
                a -= double.Parse(n.Skip(cnt++).Select(x => x).ToArray()[0]);
                b = double.Parse(n.Skip(ncnt++).Select(x => x).ToArray()[0]) - b;
            }


            Console.WriteLine(a + " " + b);
            Console.ReadLine();
        }
    }
}
0