結果

問題 No.1867 Partitions and Inversions
ユーザー SSRSSSRS
提出日時 2022-03-04 22:52:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 821 bytes
コンパイル時間 2,180 ms
コンパイル使用メモリ 203,012 KB
実行使用メモリ 38,924 KB
最終ジャッジ日時 2023-09-26 02:04:25
合計ジャッジ時間 7,762 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 70 ms
38,684 KB
testcase_03 AC 69 ms
38,688 KB
testcase_04 AC 70 ms
38,684 KB
testcase_05 AC 70 ms
38,616 KB
testcase_06 AC 70 ms
38,692 KB
testcase_07 AC 69 ms
38,720 KB
testcase_08 AC 69 ms
38,924 KB
testcase_09 AC 69 ms
38,744 KB
testcase_10 AC 69 ms
38,664 KB
testcase_11 AC 69 ms
38,688 KB
testcase_12 AC 69 ms
38,740 KB
testcase_13 AC 69 ms
38,676 KB
testcase_14 AC 70 ms
38,808 KB
testcase_15 AC 68 ms
38,672 KB
testcase_16 AC 71 ms
38,688 KB
testcase_17 AC 70 ms
38,664 KB
testcase_18 AC 69 ms
38,676 KB
testcase_19 AC 70 ms
38,788 KB
testcase_20 AC 69 ms
38,620 KB
testcase_21 AC 68 ms
38,676 KB
testcase_22 AC 70 ms
38,736 KB
testcase_23 AC 69 ms
38,624 KB
testcase_24 AC 70 ms
38,816 KB
testcase_25 AC 69 ms
38,740 KB
testcase_26 AC 68 ms
38,688 KB
testcase_27 AC 72 ms
38,684 KB
testcase_28 AC 70 ms
38,924 KB
testcase_29 AC 70 ms
38,724 KB
testcase_30 WA -
testcase_31 AC 70 ms
38,736 KB
testcase_32 AC 1 ms
4,384 KB
testcase_33 AC 1 ms
4,380 KB
testcase_34 WA -
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
testcase_37 AC 1 ms
4,384 KB
testcase_38 AC 4 ms
4,380 KB
testcase_39 AC 4 ms
4,412 KB
testcase_40 AC 4 ms
4,380 KB
testcase_41 AC 4 ms
4,420 KB
testcase_42 AC 4 ms
4,424 KB
testcase_43 AC 32 ms
19,172 KB
testcase_44 AC 33 ms
19,100 KB
testcase_45 AC 33 ms
19,288 KB
testcase_46 AC 35 ms
19,040 KB
testcase_47 AC 33 ms
19,104 KB
testcase_48 AC 33 ms
19,152 KB
testcase_49 AC 33 ms
19,160 KB
testcase_50 AC 32 ms
19,036 KB
testcase_51 AC 32 ms
19,036 KB
testcase_52 AC 32 ms
19,136 KB
testcase_53 AC 32 ms
19,224 KB
testcase_54 AC 32 ms
19,104 KB
testcase_55 AC 32 ms
19,080 KB
testcase_56 AC 32 ms
19,100 KB
testcase_57 AC 32 ms
19,336 KB
testcase_58 AC 32 ms
19,344 KB
testcase_59 AC 32 ms
19,092 KB
testcase_60 AC 34 ms
19,088 KB
testcase_61 AC 32 ms
19,032 KB
testcase_62 AC 32 ms
19,032 KB
testcase_63 AC 59 ms
38,624 KB
testcase_64 AC 2 ms
4,380 KB
testcase_65 AC 1 ms
4,380 KB
testcase_66 AC 2 ms
4,380 KB
testcase_67 AC 56 ms
38,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++){
    cin >> P[i];
    P[i]--;
  }
  vector<vector<int>> S(N + 1, vector<int>(N + 1, 0));
  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      if (P[i] > P[j]){
        S[i][j + 1]++;
      }
    }
  }
  
  for (int i = 0; i <= N; i++){
    for (int j = 0; j < N; j++){
      S[i][j + 1] += S[i][j];
    }
  }
  for (int i = N; i >= 1; i--){
    for (int j = 0; j <= N; j++){
      S[i - 1][j] += S[i][j];
    }
  }
  vector<int> mx(N + 1, 0);
  for (int i = 0; i <= N; i++){
    for (int j = i; j <= N; j++){
      mx[j - i] = max(mx[j - i], S[i][j]);
    }
  }
  for (int i = 1; i <= N; i++){
    cout << S[0][N] - mx[N + 1 -i] << endl;
  }
}
0