結果

問題 No.2210 equence Squence Seuence
ユーザー kztasakztasa
提出日時 2023-02-10 21:56:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 4,774 bytes
コンパイル時間 4,079 ms
コンパイル使用メモリ 235,308 KB
実行使用メモリ 6,344 KB
最終ジャッジ日時 2023-09-21 23:10:03
合計ジャッジ時間 6,604 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 17 ms
4,376 KB
testcase_04 AC 19 ms
4,380 KB
testcase_05 AC 29 ms
4,380 KB
testcase_06 AC 25 ms
4,380 KB
testcase_07 AC 63 ms
5,652 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,504 KB
testcase_12 AC 2 ms
4,384 KB
testcase_13 AC 79 ms
6,180 KB
testcase_14 AC 78 ms
6,256 KB
testcase_15 AC 79 ms
6,320 KB
testcase_16 AC 79 ms
6,344 KB
testcase_17 AC 79 ms
6,176 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,384 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 61 ms
5,812 KB
testcase_24 AC 46 ms
4,868 KB
testcase_25 AC 53 ms
5,440 KB
testcase_26 AC 72 ms
6,236 KB
testcase_27 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
#include <atcoder/all>

#define pub push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (ll i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
using ll = long long;
using Pll = pair<ll, ll>;


using namespace atcoder;
using mint = modint998244353;
using mint2 = modint1000000007;

constexpr long long INF = (1LL << 60);
constexpr double EPS = 1e-9;
constexpr double PI = 3.141592653589;


template <typename T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;  // aをbで更新
        return true;
    }
    return false;
}

template <typename T>
T sq(T x) {
    return x * x;
}

std::string zfill(int n, const int width)
{
    std::stringstream ss;
    ss << std::setw(width) << std::setfill('0') << n;
    return ss.str();
}


//多倍長整数を(string→vector)に変換
vector<ll> digit(string s) {
    ll n = s.size();
    vector<ll> d(n);
    rep(i, n) {
        d[i] = s[i] - '0';
    }
    return d;
}


//多倍長整数の足し算
vector<ll> adds(vector<ll> s, vector<ll> t) {
    ll n = s.size();
    ll m = t.size();
    if (n > m) { swap(s, t); n = s.size(); m = t.size(); }
    reverse(ALL(s));
    reverse(ALL(t));
    rep(i, m - n) {
        s.pub(0);
    }
    bool kuriage = false;
    rep(i, m) {
        ll a = s[i];
        ll b = t[i];
        ll c = a + b;
        if (kuriage) {
            c++;
        }
        if (c >= 10) {
            c -= 10; kuriage = true;
        }
        else {
            kuriage = false;
        }
        t[i] = c;
    }
    if (kuriage) {
        t.pub(1);
    }
    reverse(ALL(t));
    return t;
}


vector<ll> carry_and_fix(vector<ll> digit) {
    int N = digit.size();

    for (int i = 0; i < N - 1; ++i) {
        // 繰り上がり処理 (K は繰り上がりの回数)
        if (digit[i] >= 10) {
            int K = digit[i] / 10;
            digit[i] -= K * 10;
            digit[i + 1] += K;
        }
        // 繰り下がり処理 (K は繰り下がりの回数)
        if (digit[i] < 0) {
            int K = (-digit[i] - 1) / 10 + 1;
            digit[i] += K * 10;
            digit[i + 1] -= K;
        }
    }
    // 一番上の桁が 10 以上なら、桁数を増やすことを繰り返す
    while (digit.back() >= 10) {
        int K = digit.back() / 10;
        digit.back() -= K * 10;
        digit.push_back(K);
    }
    // 1 桁の「0」以外なら、一番上の桁の 0 (リーディング・ゼロ) を消す
    while (digit.size() >= 2 && digit.back() == 0) {
        digit.pop_back();
    }
    reverse(ALL(digit));
    return digit;
}


//多倍長整数の掛け算(s × t) 計算量は N(|s||t|)?
vector<ll> mul(vector<ll> s, vector<ll> t) {
    reverse(ALL(s));
    reverse(ALL(t));
    ll NA = s.size();
    ll NB = t.size();
    vector<ll> res(NA + NB - 1);
    for (int i = 0; i < NA; ++i) {
        for (int j = 0; j < NB; ++j) {
            res[i + j] += s[i] * t[j];
        }
    }
    return carry_and_fix(res);
}


/*  make_is_prime(N)
    入力:整数 N
    出力:N までの数字が素数か判定したベクトル(i番目がtrueならiは素数)
    計算量:O(nloglogn)
*/
vector< bool > prime_table(int n) {
    vector< bool > prime(n + 1, true);
    if (n >= 0) prime[0] = false;
    if (n >= 1) prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!prime[i]) continue;
        for (int j = i + i; j <= n; j += i) {
            prime[j] = false;
        }
    }
    return prime;
}

int main() {
    //cout << fixed << setprecision(10);
    ll N, K; cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) {
        cin >> A[i];
    }
    deque<ll> B;
    B.push_back(N - 1);
    bool front = true, back = true;
    per(i, N-1) {
        if (A[i] < A[i + 1]) {
            B.push_back(i);
            back = true;
            front = false;
        }
        else if (A[i] > A[i+1]){
            B.push_front(i);
            front = true;
            back = false;
        }
        else {
            if (front) {
                B.push_front(i);
            }
            else if (back) {
                B.push_back(i);
            }
        }
    }
    ll v = INF;
    while (K) {
        K--;
        v = B.front();
        B.pop_front();
    }
    rep(i, N) {
        if (i == v) {
            continue;
        }
        else {
            cout << A[i] << " ";
        }
    }
    cout << endl;
}







0