結果

問題 No.2210 equence Squence Seuence
ユーザー Nzt3Nzt3
提出日時 2023-02-11 08:08:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 674 bytes
コンパイル時間 2,478 ms
コンパイル使用メモリ 201,376 KB
実行使用メモリ 4,972 KB
最終ジャッジ日時 2023-09-22 07:14:13
合計ジャッジ時間 6,671 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 12 ms
4,380 KB
testcase_07 AC 28 ms
4,660 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 34 ms
4,828 KB
testcase_14 AC 36 ms
4,828 KB
testcase_15 AC 36 ms
4,876 KB
testcase_16 AC 35 ms
4,740 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 26 ms
4,740 KB
testcase_24 AC 20 ms
4,380 KB
testcase_25 AC 23 ms
4,608 KB
testcase_26 AC 31 ms
4,836 KB
testcase_27 AC 10 ms
4,380 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>ans;
  for(int i=0,cnt=0;i<N-1;i++){
    if(K-cnt<=0&&A[i+1]<A[i]){
      for(int j=i+1;j<N;j++){
        ans.push_back(A[j]);
      }
      break;
    }
    if(A[i+1]>A[i]&&N-1-i<=K&&N-1-i>=K-cnt){
      for(int j=i+1;j<N;j++){
        ans.push_back(A[j]);
      }
      break;
    }
    ans.push_back(A[i]);
    if(A[i+1]<A[i]){
      K-=cnt+1;
      cnt=0;
    }else if(A[i+1]==A[i]){
      ++cnt;
    }
  }
  for(int i=0;i<N-1;i++){
    cout<<ans[i]<<(i==N-2?'\n':' ');
  }
}
0