結果

問題 No.2774 Wake up Record 2
ユーザー 👑 seekworserseekworser
提出日時 2024-05-31 23:17:33
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 857 bytes
コンパイル時間 3,444 ms
コンパイル使用メモリ 276,504 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-06 22:55:35
合計ジャッジ時間 4,712 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 WA -
testcase_02 AC 2 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 16 ms
5,376 KB
testcase_12 AC 10 ms
5,376 KB
testcase_13 AC 31 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 49 ms
5,376 KB
testcase_17 AC 52 ms
5,376 KB
testcase_18 AC 34 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int j = 0; j < n; j++)
        cin >> a[j];
    int r = 1000000000, l = 1;
    int now;
    while (r > l)
    {
        now = (r + l) / 2;
        int count = 0;
        for (int j : a)
        {
            if (j <= now)
                count++;
        }
        if (count == k)
            break;
        else if (count < k)
        {
            l = now + 1;
        }
        else
        {
            r = now;
        }
    }
    vector<int> ans(0);
    for (int j = 1; j < n; j++)
    {
        if (a[j - 1] <= now && a[j] > now)
        {
            ans.push_back(j + 1);
        }
    }
    cout << ans.size() << endl;
    for (int i=0; i<ans.size(); i++) { cout << ans[i] << " \n"[i == ans.size() - 1];}
    return 0;
}
0