結果

問題 No.1425 Yet Another Cyclic Shifts Sorting
ユーザー SSRSSSRS
提出日時 2021-03-12 21:47:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 1,814 ms
コンパイル使用メモリ 174,988 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-04-22 12:38:37
合計ジャッジ時間 6,859 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 1 ms
5,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 WA -
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 122 ms
12,416 KB
testcase_23 AC 28 ms
5,504 KB
testcase_24 AC 23 ms
5,376 KB
testcase_25 AC 127 ms
12,928 KB
testcase_26 AC 152 ms
14,848 KB
testcase_27 AC 133 ms
13,312 KB
testcase_28 AC 159 ms
14,720 KB
testcase_29 AC 44 ms
6,656 KB
testcase_30 AC 33 ms
5,632 KB
testcase_31 AC 158 ms
14,592 KB
testcase_32 AC 42 ms
6,400 KB
testcase_33 AC 6 ms
5,376 KB
testcase_34 AC 49 ms
7,040 KB
testcase_35 AC 151 ms
13,824 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<pair<int, int>> A2(N);
  for (int i = 0; i < N; i++){
    A2[i] = make_pair(A[i], i);
  }
  sort(A2.begin(), A2.end());
  set<pair<int, int>> st;
  for (int i = 0; i < N; i++){
    st.insert(make_pair(i, A[i]));
  }
  int ans = 0;
  auto itr = st.end();
  for (int i = 0; i < N - 1; i++){
    auto itr2 = itr;
    if (itr2 == st.begin()){
      itr2 = prev(st.end());
    } else {
      itr2 = prev(itr);
    }
    if ((*itr2).second != A2[N - 1 - i].first){
      ans++;
      itr2 = st.find(make_pair(A2[N - 1 - i].second, A2[N - 1 - i].first));
    }
    itr = st.erase(itr2);
  }
  cout << ans << endl;
}
0