結果

問題 No.2774 Wake up Record 2
ユーザー Dương Nguyễn CảnhDương Nguyễn Cảnh
提出日時 2024-06-07 21:37:01
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,692 bytes
コンパイル時間 2,135 ms
コンパイル使用メモリ 208,992 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-26 07:20:38
合計ジャッジ時間 3,029 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx2,fma,bmi,bmi2,sse4.2,popcnt,lzcnt")
*/

#include <bits/stdc++.h>
#define taskname ""
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define i64 long long
#define pb push_back
#define ff first
#define ss second
#define isz(x) (int)x.size()
using namespace std;

const int mxN = 2e5 + 5;
const int mod = 1e9 + 7;
const i64 oo = 1e18;

void solve() {
    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    for (auto &val : a) cin >> val;

    vector<int> idx(n);
    iota(all(idx), 0);
    sort(all(idx), [&](int x, int y) {
        return a[x] < a[y];
    });

    for (int i = 0; i < k; ++i) a[idx[i]] = -1;

    int pre = -1;
    vector<int> res;
    for (int i = 0; i < n; ++i) {
        if (pre == -1 and a[i] != -1) res.emplace_back(i + 1);
        pre = a[i];
    }
    cout << isz(res) << endl;
    for (auto val : res) cout << val << " ";
    cout << endl;
}

signed main() {

#ifndef CDuongg
    if(fopen(taskname".inp", "r"))
        assert(freopen(taskname".inp", "r", stdin)), assert(freopen(taskname".out", "w", stdout));
#else
    freopen("bai3.inp", "r", stdin);
    freopen("bai3.out", "w", stdout);
    auto start = chrono::high_resolution_clock::now();
#endif

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1; //cin >> t;
    while(t--) solve();

#ifdef CDuongg
   auto end = chrono::high_resolution_clock::now();
   cout << "\n"; for(int i = 1; i <= 100; ++i) cout << '=';
   cout << "\nExecution time: " << chrono::duration_cast<chrono::milliseconds> (end - start).count() << "[ms]" << endl;
   cout << "Check array size pls sir" << endl;
#endif

}
0