結果

問題 No.2210 equence Squence Seuence
ユーザー tnakao0123tnakao0123
提出日時 2023-04-23 01:08:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 44 ms / 2,000 ms
コード長 846 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 42,952 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 02:08:06
合計ジャッジ時間 3,097 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 11 ms
5,376 KB
testcase_04 AC 12 ms
5,376 KB
testcase_05 AC 16 ms
5,376 KB
testcase_06 AC 14 ms
5,376 KB
testcase_07 AC 35 ms
5,376 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 1 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 43 ms
5,376 KB
testcase_14 AC 44 ms
5,376 KB
testcase_15 AC 43 ms
5,376 KB
testcase_16 AC 43 ms
5,376 KB
testcase_17 AC 42 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 34 ms
5,376 KB
testcase_24 AC 26 ms
5,376 KB
testcase_25 AC 29 ms
5,376 KB
testcase_26 AC 40 ms
5,376 KB
testcase_27 AC 12 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2210.cc:  No.2210 equence Squence Seuence - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

/* global variables */

int as[MAX_N], xs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  k--;
  int r = -1;
  
  for (int i = 0, c = 1; r < 0 && i + 1 < n; i++) {
    if (as[i] < as[i + 1]) {
      if (k >= n - i - c) r = i;
      c = 1;
    }
    else if (as[i] > as[i + 1]) {
      if (k < c) r = i;
      k -= c;
      c = 1;
    }
    else {
      c++;
    }
  }

  for (int i = 0, j = 0; i < n; i++)
    if (i != r) xs[j++] = as[i];

  for (int i = 0; i < n - 1; i++)
    printf("%d%c", xs[i], (i + 2 < n) ? ' ' : '\n');
  return 0;
}
0