結果

問題 No.1867 Partitions and Inversions
ユーザー 👑 NachiaNachia
提出日時 2022-03-04 23:40:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,722 ms / 5,000 ms
コード長 865 bytes
コンパイル時間 1,096 ms
コンパイル使用メモリ 83,216 KB
実行使用メモリ 38,524 KB
最終ジャッジ日時 2023-09-26 02:46:47
合計ジャッジ時間 129,723 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3,410 ms
38,204 KB
testcase_03 AC 3,369 ms
38,464 KB
testcase_04 AC 3,314 ms
38,204 KB
testcase_05 AC 3,209 ms
38,224 KB
testcase_06 AC 3,227 ms
38,288 KB
testcase_07 AC 3,252 ms
38,220 KB
testcase_08 AC 3,355 ms
38,200 KB
testcase_09 AC 3,302 ms
38,216 KB
testcase_10 AC 3,271 ms
38,364 KB
testcase_11 AC 3,166 ms
38,196 KB
testcase_12 AC 3,356 ms
38,196 KB
testcase_13 AC 3,122 ms
38,328 KB
testcase_14 AC 3,114 ms
38,200 KB
testcase_15 AC 3,298 ms
38,412 KB
testcase_16 AC 3,398 ms
38,424 KB
testcase_17 AC 3,286 ms
38,308 KB
testcase_18 AC 3,355 ms
38,416 KB
testcase_19 AC 3,272 ms
38,308 KB
testcase_20 AC 3,297 ms
38,464 KB
testcase_21 AC 3,506 ms
38,288 KB
testcase_22 AC 3,544 ms
38,204 KB
testcase_23 AC 3,420 ms
38,416 KB
testcase_24 AC 3,369 ms
38,200 KB
testcase_25 AC 3,322 ms
38,208 KB
testcase_26 AC 3,347 ms
38,212 KB
testcase_27 AC 3,271 ms
38,196 KB
testcase_28 AC 3,374 ms
38,524 KB
testcase_29 AC 3,230 ms
38,208 KB
testcase_30 AC 3,370 ms
38,364 KB
testcase_31 AC 3,293 ms
38,468 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,380 KB
testcase_38 AC 17 ms
8,420 KB
testcase_39 AC 17 ms
8,352 KB
testcase_40 AC 16 ms
8,500 KB
testcase_41 AC 17 ms
8,424 KB
testcase_42 AC 17 ms
8,348 KB
testcase_43 AC 895 ms
27,784 KB
testcase_44 AC 887 ms
28,004 KB
testcase_45 AC 922 ms
27,868 KB
testcase_46 AC 954 ms
27,784 KB
testcase_47 AC 911 ms
27,872 KB
testcase_48 AC 911 ms
27,776 KB
testcase_49 AC 902 ms
28,088 KB
testcase_50 AC 929 ms
27,940 KB
testcase_51 AC 903 ms
27,800 KB
testcase_52 AC 932 ms
27,784 KB
testcase_53 AC 921 ms
27,940 KB
testcase_54 AC 920 ms
27,804 KB
testcase_55 AC 910 ms
27,868 KB
testcase_56 AC 903 ms
27,844 KB
testcase_57 AC 930 ms
27,820 KB
testcase_58 AC 925 ms
27,864 KB
testcase_59 AC 911 ms
27,796 KB
testcase_60 AC 915 ms
27,792 KB
testcase_61 AC 898 ms
27,868 KB
testcase_62 AC 900 ms
27,824 KB
testcase_63 AC 3,367 ms
38,288 KB
testcase_64 AC 2 ms
4,376 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 2 ms
4,376 KB
testcase_67 AC 3,722 ms
30,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using i64 = long long;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


int N;
int P[3000];
int I[3001][3001];
int dp[3001] = {};
int ans[3001] = {};

int main(){
    int N; cin >> N;
    rep(i,N){ cin >> P[i]; P[i]--; }
    rep(i,N) rep(j,i) if(P[j] > P[i]) I[j][i+1]++;
    for(int l=N; l>=0; l--) for(int r=l+1; r<=N; r++) I[l][r] += I[l+1][r];
    for(int l=N; l>=0; l--) for(int r=l+1; r<=N; r++) I[l][r] += I[l][r-1];

    for(int k=0; k<N; k++){
        for(int l=0; l+k<N; l++){
            dp[l] = 0;
            for(int r=l+1; r+k<=N; r++){
                dp[l] = max(dp[l], dp[r] + I[l][r]);
            }
        }
        cout << (I[0][N] - dp[0]) << '\n';
    }

    return 0;
}
0