結果
問題 | No.2803 Bocching Star |
ユーザー |
|
提出日時 | 2024-07-12 21:24:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 1,088 bytes |
コンパイル時間 | 1,929 ms |
コンパイル使用メモリ | 179,156 KB |
実行使用メモリ | 9,812 KB |
最終ジャッジ日時 | 2024-07-12 21:24:44 |
合計ジャッジ時間 | 5,455 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>using namespace std;#ifndef ONLINE_JUDGE#include "algo/debug.h"#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)#else#define debug(x...)#endif#define int long longvoid solve() {int n, s;cin >> n >> s;vector<pair<int, int>> a;for (int i = 0, x; i < n; i++) {cin >> x;a.push_back({x, i + 1});}sort(a.begin(), a.end());vector<int> ans;for (int i = 0; i < n; i++) {bool ok = 1;if (i) {if (a[i].first - a[i - 1].first <= s) {ok = false;}}if (i < n - 1) {if (a[i + 1].first - a[i].first <= s) {ok = false;}}if (ok) {ans.push_back(a[i].second);}}sort(ans.begin(), ans.end());cout << ans.size() << '\n';for (auto &x : ans) {cout << x << " ";}}signed main() {#ifndef ONLINE_JUDGEfreopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);#else#endifios::sync_with_stdio(0); cin.tie(0); cout.tie(0);int t = 1;//cin >> t;while (t--) {solve();}// cerr << "Time elapsed: " << ((long double)clock() / CLOCKS_PER_SEC) << " s.\n";}