結果

問題 No.2210 equence Squence Seuence
ユーザー Nzt3
提出日時 2023-02-11 09:11:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 2,177 ms
コンパイル使用メモリ 200,376 KB
最終ジャッジ日時 2025-02-10 14:11:29
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

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