結果
問題 | No.2806 Cornflake Man |
ユーザー | Kude |
提出日時 | 2024-07-12 22:37:59 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 159 ms / 2,000 ms |
コード長 | 1,274 bytes |
コンパイル時間 | 3,524 ms |
コンパイル使用メモリ | 281,796 KB |
実行使用メモリ | 22,784 KB |
最終ジャッジ日時 | 2024-07-17 20:27:31 |
合計ジャッジ時間 | 5,350 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 48 ms
14,080 KB |
testcase_01 | AC | 118 ms
18,944 KB |
testcase_02 | AC | 13 ms
6,272 KB |
testcase_03 | AC | 124 ms
19,584 KB |
testcase_04 | AC | 12 ms
5,632 KB |
testcase_05 | AC | 23 ms
7,040 KB |
testcase_06 | AC | 28 ms
9,600 KB |
testcase_07 | AC | 159 ms
21,888 KB |
testcase_08 | AC | 26 ms
9,068 KB |
testcase_09 | AC | 74 ms
13,312 KB |
testcase_10 | AC | 35 ms
8,320 KB |
testcase_11 | AC | 6 ms
5,376 KB |
testcase_12 | AC | 48 ms
9,472 KB |
testcase_13 | AC | 102 ms
15,744 KB |
testcase_14 | AC | 18 ms
6,016 KB |
testcase_15 | AC | 137 ms
22,784 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 2 ms
5,376 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 2 ms
5,376 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; VI a(n); rep(i, n) cin >> a[i]; sort(all(a)); a.erase(a.begin()); set<int> sa(all(a)), todo(all(a)); VI ans; while (todo.size()) { int x = *todo.begin(); ans.emplace_back(x); for (int xk = x; xk <= m; xk += x) { if (!sa.contains(xk)) { cout << -1 << '\n'; return 0; } todo.erase(xk); } } int sz = ans.size(); cout << sz << '\n'; rep(i, sz) cout << ans[i] << " \n"[i + 1 == sz]; }