結果

問題 No.2774 Wake up Record 2
ユーザー NAMIDAIRONAMIDAIRO
提出日時 2024-06-07 21:31:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 1,134 bytes
コンパイル時間 1,045 ms
コンパイル使用メモリ 122,016 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-07 21:31:25
合計ジャッジ時間 1,984 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 4 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 14 ms
5,376 KB
testcase_12 AC 9 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 40 ms
5,376 KB
testcase_15 AC 39 ms
5,376 KB
testcase_16 AC 40 ms
5,376 KB
testcase_17 AC 42 ms
5,376 KB
testcase_18 AC 27 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <random>
#include <iomanip>
#include <string>
#include <cmath>
#include <complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)

template<class T>
using vi = vector<T>;

template<class T>
using vii = vector<vi<T>>;

template<class T>
using viii = vector<vii<T>>;

template<class T>
using viiii = vector<viii<T>>;

using P = pair<ll, int>;

void chmin(ll & x, ll y) { x = min(x, y); }

void chmax(ll& x, ll y) { x = max(x, y); }

int main()
{
    int n, k;
    cin >> n >> k;
    vi<int> a(n);
    rep(i, n) cin >> a[i];
    vi<int> b = a;
    sort(b.begin(), b.end());

    int thre = b[k - 1];    
    string s;
    rep(i, n) {
        if (a[i] <= thre) s.push_back('x');
        else s.push_back('o');
    }

    vi<int> ans;
    rep(i, n - 1) {
        if (s[i] == 'x' && s[i + 1] == 'o') ans.push_back(i + 2);
    }
    int sz = (int)ans.size();
    cout << sz << endl;
    rep(i, sz) cout << ans[i] << " \n"[i == sz - 1];
    if (sz == 0) cout << endl;
    return 0;
}

0