結果

問題 No.2210 equence Squence Seuence
ユーザー SSRSSSRS
提出日時 2023-02-10 21:27:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 979 bytes
コンパイル時間 1,622 ms
コンパイル使用メモリ 175,664 KB
実行使用メモリ 6,416 KB
最終ジャッジ日時 2023-09-21 22:29:31
合計ジャッジ時間 4,403 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 19 ms
4,376 KB
testcase_05 AC 28 ms
4,380 KB
testcase_06 AC 25 ms
4,380 KB
testcase_07 AC 62 ms
5,648 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 76 ms
6,124 KB
testcase_14 AC 77 ms
6,260 KB
testcase_15 AC 77 ms
6,060 KB
testcase_16 AC 76 ms
6,416 KB
testcase_17 AC 77 ms
6,120 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 56 ms
4,380 KB
testcase_24 AC 43 ms
4,380 KB
testcase_25 AC 49 ms
4,380 KB
testcase_26 AC 66 ms
4,580 KB
testcase_27 AC 19 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  K--;
  vector<int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  vector<pair<int, int>> P;
  P.push_back(make_pair(A[0], 1));
  for (int i = 1; i < N; i++){
    if (A[i] == A[i - 1]){
      P.back().second++;
    } else {
      P.push_back(make_pair(A[i], 1));
    }
  }
  int cnt = P.size();
  deque<int> dq;
  for (int i = 0; i < P[cnt - 1].second; i++){
    dq.push_back(cnt - 1);
  }
  for (int i = cnt - 2; i >= 0; i--){
    if (P[i].first < P[i + 1].first){
      for (int j = 0; j < P[i].second; j++){
        dq.push_back(i);
      }
    } else {
      for (int j = 0; j < P[i].second; j++){
        dq.push_front(i);
      }
    }
  }
  int p = dq[K];
  int s = 0;
  for (int i = 0; i < p; i++){
    s += P[i].second;
  }
  A.erase(A.begin() + s);
  for (int i = 0; i < N - 1; i++){
    cout << A[i];
    if (i < N - 2){
      cout << ' ';
    }
  }
  cout << endl;
}
0