結果

問題 No.1867 Partitions and Inversions
ユーザー 👑 NachiaNachia
提出日時 2022-03-04 23:36:33
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 4,887 ms / 5,000 ms
コード長 748 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 74,924 KB
実行使用メモリ 38,508 KB
最終ジャッジ日時 2023-09-26 02:44:03
合計ジャッジ時間 177,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4,612 ms
38,212 KB
testcase_03 AC 4,594 ms
38,428 KB
testcase_04 AC 4,611 ms
38,264 KB
testcase_05 AC 4,605 ms
38,292 KB
testcase_06 AC 4,571 ms
38,376 KB
testcase_07 AC 4,665 ms
38,212 KB
testcase_08 AC 4,613 ms
38,368 KB
testcase_09 AC 4,552 ms
38,200 KB
testcase_10 AC 4,620 ms
38,268 KB
testcase_11 AC 4,493 ms
38,208 KB
testcase_12 AC 4,670 ms
38,420 KB
testcase_13 AC 4,581 ms
38,508 KB
testcase_14 AC 4,638 ms
38,364 KB
testcase_15 AC 4,705 ms
38,312 KB
testcase_16 AC 4,626 ms
38,364 KB
testcase_17 AC 4,612 ms
38,308 KB
testcase_18 AC 4,660 ms
38,384 KB
testcase_19 AC 4,563 ms
38,204 KB
testcase_20 AC 4,622 ms
38,296 KB
testcase_21 AC 4,723 ms
38,212 KB
testcase_22 AC 4,567 ms
38,296 KB
testcase_23 AC 4,648 ms
38,216 KB
testcase_24 AC 4,556 ms
38,468 KB
testcase_25 AC 4,600 ms
38,308 KB
testcase_26 AC 4,616 ms
38,380 KB
testcase_27 AC 4,594 ms
38,416 KB
testcase_28 AC 4,619 ms
38,508 KB
testcase_29 AC 4,582 ms
38,212 KB
testcase_30 AC 4,561 ms
38,380 KB
testcase_31 AC 4,567 ms
38,196 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 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 1 ms
4,380 KB
testcase_38 AC 23 ms
8,504 KB
testcase_39 AC 23 ms
8,428 KB
testcase_40 AC 23 ms
8,332 KB
testcase_41 AC 23 ms
8,496 KB
testcase_42 AC 23 ms
8,332 KB
testcase_43 AC 1,263 ms
27,872 KB
testcase_44 AC 1,300 ms
28,004 KB
testcase_45 AC 1,287 ms
27,996 KB
testcase_46 AC 1,265 ms
27,784 KB
testcase_47 AC 1,265 ms
27,940 KB
testcase_48 AC 1,272 ms
27,940 KB
testcase_49 AC 1,266 ms
27,840 KB
testcase_50 AC 1,283 ms
27,844 KB
testcase_51 AC 1,284 ms
27,792 KB
testcase_52 AC 1,260 ms
27,908 KB
testcase_53 AC 1,279 ms
27,896 KB
testcase_54 AC 1,261 ms
28,084 KB
testcase_55 AC 1,339 ms
27,784 KB
testcase_56 AC 1,273 ms
27,876 KB
testcase_57 AC 1,274 ms
27,944 KB
testcase_58 AC 1,266 ms
27,844 KB
testcase_59 AC 1,271 ms
27,960 KB
testcase_60 AC 1,263 ms
27,784 KB
testcase_61 AC 1,259 ms
28,004 KB
testcase_62 AC 1,269 ms
27,784 KB
testcase_63 AC 4,508 ms
38,368 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 1 ms
4,384 KB
testcase_67 AC 4,887 ms
30,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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]++;
    rep(r,N+1) for(int l=r-1; l>=0; l--) I[l][r] += I[l+1][r];
    rep(r,N+1) for(int l=r-1; l>=0; l--) 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