結果

問題 No.1867 Partitions and Inversions
ユーザー 👑 NachiaNachia
提出日時 2022-03-04 23:55:50
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,321 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 1,020 ms
コンパイル使用メモリ 83,016 KB
実行使用メモリ 50,960 KB
最終ジャッジ日時 2023-09-26 03:34:50
合計ジャッジ時間 124,283 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 3,245 ms
50,672 KB
testcase_03 AC 3,246 ms
50,700 KB
testcase_04 AC 3,127 ms
50,724 KB
testcase_05 AC 3,224 ms
50,740 KB
testcase_06 AC 3,157 ms
50,764 KB
testcase_07 AC 3,261 ms
50,660 KB
testcase_08 AC 3,146 ms
50,676 KB
testcase_09 AC 3,294 ms
50,680 KB
testcase_10 AC 3,220 ms
50,868 KB
testcase_11 AC 3,276 ms
50,660 KB
testcase_12 AC 3,123 ms
50,700 KB
testcase_13 AC 3,219 ms
50,728 KB
testcase_14 AC 3,095 ms
50,664 KB
testcase_15 AC 3,244 ms
50,732 KB
testcase_16 AC 3,169 ms
50,752 KB
testcase_17 AC 3,321 ms
50,700 KB
testcase_18 AC 3,216 ms
50,680 KB
testcase_19 AC 3,270 ms
50,660 KB
testcase_20 AC 3,215 ms
50,672 KB
testcase_21 AC 3,229 ms
50,684 KB
testcase_22 AC 3,148 ms
50,720 KB
testcase_23 AC 3,214 ms
50,676 KB
testcase_24 AC 3,125 ms
50,960 KB
testcase_25 AC 3,209 ms
50,688 KB
testcase_26 AC 3,152 ms
50,696 KB
testcase_27 AC 3,306 ms
50,676 KB
testcase_28 AC 3,217 ms
50,740 KB
testcase_29 AC 3,294 ms
50,828 KB
testcase_30 AC 3,141 ms
50,760 KB
testcase_31 AC 3,238 ms
50,664 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 18 ms
10,324 KB
testcase_39 AC 19 ms
9,984 KB
testcase_40 AC 18 ms
10,076 KB
testcase_41 AC 18 ms
10,324 KB
testcase_42 AC 18 ms
10,140 KB
testcase_43 AC 879 ms
35,624 KB
testcase_44 AC 883 ms
35,712 KB
testcase_45 AC 883 ms
35,644 KB
testcase_46 AC 885 ms
35,792 KB
testcase_47 AC 867 ms
35,680 KB
testcase_48 AC 889 ms
35,584 KB
testcase_49 AC 890 ms
35,704 KB
testcase_50 AC 893 ms
35,736 KB
testcase_51 AC 881 ms
35,616 KB
testcase_52 AC 892 ms
35,592 KB
testcase_53 AC 890 ms
35,576 KB
testcase_54 AC 904 ms
35,672 KB
testcase_55 AC 885 ms
35,576 KB
testcase_56 AC 886 ms
35,792 KB
testcase_57 AC 888 ms
35,796 KB
testcase_58 AC 902 ms
35,644 KB
testcase_59 AC 895 ms
35,628 KB
testcase_60 AC 892 ms
35,672 KB
testcase_61 AC 886 ms
35,604 KB
testcase_62 AC 889 ms
35,600 KB
testcase_63 AC 3,243 ms
50,684 KB
testcase_64 AC 1 ms
4,376 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 2 ms
4,376 KB
testcase_67 AC 3,237 ms
37,876 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[4096];
int I[3001][4096];
int dp[4096] = {};
int ans[4096] = {};

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