結果

問題 No.1837 Same but Different
ユーザー 👑 kakel-sankakel-san
提出日時 2022-02-11 23:18:25
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,037 bytes
コンパイル時間 982 ms
コンパイル使用メモリ 65,300 KB
実行使用メモリ 24,752 KB
最終ジャッジ日時 2023-09-10 06:10:03
合計ジャッジ時間 4,317 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,764 KB
testcase_01 AC 60 ms
22,764 KB
testcase_02 AC 58 ms
18,704 KB
testcase_03 AC 58 ms
20,760 KB
testcase_04 AC 59 ms
20,672 KB
testcase_05 AC 59 ms
22,656 KB
testcase_06 AC 59 ms
20,648 KB
testcase_07 AC 59 ms
20,664 KB
testcase_08 AC 61 ms
20,708 KB
testcase_09 AC 60 ms
22,740 KB
testcase_10 AC 61 ms
18,720 KB
testcase_11 AC 58 ms
20,724 KB
testcase_12 AC 60 ms
22,700 KB
testcase_13 AC 59 ms
20,680 KB
testcase_14 AC 59 ms
20,656 KB
testcase_15 AC 58 ms
20,656 KB
testcase_16 AC 58 ms
20,652 KB
testcase_17 AC 58 ms
20,720 KB
testcase_18 AC 58 ms
22,692 KB
testcase_19 AC 59 ms
24,752 KB
testcase_20 AC 58 ms
20,704 KB
testcase_21 AC 59 ms
20,776 KB
testcase_22 AC 59 ms
22,664 KB
testcase_23 AC 58 ms
18,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static void Main()
    {
        var n = NN;
        var (a, b) = Same(n);
        WriteLine(string.Join(" ", a));
        WriteLine(string.Join(" ", b));
    }
    static (int[] a, int[] b) Same(int n)
    {
        var a = new int[n];
        var b = new int[n];
        for (var i = 0; i < n; ++i)
        {
            a[i] = 3 * (i + 1);
            b[i] = 3 * (i + 1) + 1;
        }
        a[n - 1] += 3;
        var rest = n - 3;
        if (n % 3 == 2)
        {
            a[n - 2] += 10;
            a[n - 1] += 19;
            b[n - 2] += 12;
            b[n - 1] += 15;
            rest -= 2;
        }
        else if (n % 3 == 1)
        {
            ++a[n - 1];
            --rest;
        }
        for (var i = 0; i < n; ++i)
        {
            if (rest <= 0) break;
            b[i] -= 3;
            rest -= 3;
        }
        return (a, b);
    }
}
0