結果

問題 No.1837 Same but Different
ユーザー 👑 hitonanodehitonanode
提出日時 2021-12-12 12:42:56
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,212 bytes
コンパイル時間 933 ms
コンパイル使用メモリ 92,060 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 04:48:57
合計ジャッジ時間 3,798 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);
    int N;
    cin >> N;
    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 - 1; i >= 0; --i) {
            while (A[i] + 3 < 9900 and A[i] + 3 < B.back() - 3 and B.back() > 10000) {
                if (i + 1 < N and A[i] + 3 >= A[i + 1]) break;
                A[i] += 3;
                B.back() -= 3;
            }
        }
    }
    for (auto x : A) cout << x << ' ';
    cout << '\n';
    for (auto x : B) cout << x << ' ';
    cout << '\n';
    cerr << p << endl;
    cerr << A.size() << ' ' << accumulate(A.begin(), A.end(), 0LL) << '\n';
    cerr << B.size() << ' ' << accumulate(B.begin(), B.end(), 0LL) << '\n';
}
0