結果

問題 No.2210 equence Squence Seuence
ユーザー Nzt3Nzt3
提出日時 2023-02-11 09:11:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 2,441 ms
コンパイル使用メモリ 207,796 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-07-08 00:30:59
合計ジャッジ時間 4,787 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 10 ms
5,376 KB
testcase_04 AC 11 ms
5,376 KB
testcase_05 AC 15 ms
5,376 KB
testcase_06 AC 13 ms
5,376 KB
testcase_07 AC 31 ms
5,720 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 40 ms
5,896 KB
testcase_14 AC 39 ms
5,896 KB
testcase_15 AC 39 ms
6,028 KB
testcase_16 AC 39 ms
5,896 KB
testcase_17 AC 38 ms
5,896 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 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 28 ms
6,144 KB
testcase_24 AC 22 ms
5,376 KB
testcase_25 AC 25 ms
5,888 KB
testcase_26 AC 34 ms
6,400 KB
testcase_27 AC 11 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N,K;
  cin>>N>>K;
  --K;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  vector<int>P(N);
  queue<int>Q;
  int L=0,R=N-1;
  for(int i=0;i<N-1;i++){
    Q.push(i);
    if(A[i]>A[i+1]){
      while(Q.size()){
        P[L++]=Q.front();
        Q.pop();
      }
    }else if(A[i]<A[i+1]){
      while(Q.size()){
        P[R--]=Q.front();
        Q.pop();
      }
    }
  }
  Q.push(N-1);
  while(Q.size()){
    P[L++]=Q.front();
    Q.pop();
  }
  vector<int>ans;
  for(int i=0;i<N;i++){
    if(i==P[K])continue;
    ans.push_back(A[i]);
  }
  for(int i=0;i<N-1;i++){
    cout<<ans[i]<<(i==N-2?'\n':' ');
  }
}
0