結果

問題 No.2038 Strange Arrange
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2022-08-13 07:20:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 674 bytes
コンパイル時間 1,590 ms
コンパイル使用メモリ 171,904 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 23:19:34
合計ジャッジ時間 2,113 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2022.08.13 07:19:58
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;


int main() {
    int n;cin >> n;
    vector<int> a(n+1);
    vector<int> b(n+1,0);
    vector<vector<int>> c(10);
    a[0] = -100;
    for (int i = 0; i < n; i++) {
        a[i+1] = a[i]==b[i+1]+1?a[i]+1:b[i+1]+1;
        for (int j = 0; j < c[a[i+1]-1].size(); j++) {
            int k = c[a[i+1]-1][j];
            if (k+i+1 <= n) b[k+i+1] = max(b[k+i+1],a[i+1]);
        }
        c[a[i+1]-1].push_back(i+1);
    }
    for (int i = 0; i < n; i++) {
        cout << a[i+1];
    }
    cout << endl;
    return 0;
}
0