結果

問題 No.1837 Same but Different
ユーザー 👑 hitonanodehitonanode
提出日時 2021-12-19 16:13:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,261 bytes
コンパイル時間 6,274 ms
コンパイル使用メモリ 213,256 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-13 18:49:44
合計ジャッジ時間 7,620 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,352 KB
testcase_18 AC 2 ms
4,352 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,352 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 2 ms
4,352 KB
testcase_23 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Validator
#include "testlib.h"
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main(int argc, char **argv) {

    registerValidation(argc, argv);
    int N = inf.readInt(3, 3000);
    inf.readEoln();
    inf.readEof();

    if (N == 4) {
        puts("1 2 3 120");
        puts("30 31 32 33");
        return 0;
    }
    int p = 3;
    // [0, 0, 0, 0, ..., 0] vs. [1, 1, 1, 1, ..., -(N - 1)]
    // while ((N - 2) % p == 0) ++p;
    vector<int> A{3}, B{7};
    if ((N - 2) % p == 0) A[0]++;
    for (int i = 10; i <= 10000; ++i) {
        if (i % p == 0 and int(A.size()) < N) A.push_back(i);
        if (i % p == 1 and int(B.size()) < N - 1) B.push_back(i);
    }
    B.push_back(accumulate(A.begin(), A.end(), 0LL) - accumulate(B.begin(), B.end(), 0LL));

    while (B.back() > 10000) {
        for (int i = N - 2; i >= 0; --i) {
            while (B[i] + 3 < 9900 and B[i] + 3 < B.back() - 3 and B.back() > 10000) {
                if (i + 1 < N and B[i] + 3 >= B[i + 1]) break;
                B[i] += 3;
                B.back() -= 3;
            }
        }
    }
    for (int i = 0; i < N; ++i) cout << A[i] << (i + 1 == N ? '\n' : ' ');
    for (int i = 0; i < N; ++i) cout << B[i] << (i + 1 == N ? '\n' : ' ');
}
0