結果
問題 | No.2806 Cornflake Man |
ユーザー | srjywrdnprkt |
提出日時 | 2024-10-20 23:08:43 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 227 ms / 2,000 ms |
コード長 | 682 bytes |
コンパイル時間 | 2,414 ms |
コンパイル使用メモリ | 210,820 KB |
実行使用メモリ | 22,272 KB |
最終ジャッジ日時 | 2024-10-20 23:08:50 |
合計ジャッジ時間 | 5,991 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; int main(){ cin.tie(nullptr); ios_base::sync_with_stdio(false); int N, M, A, x; cin >> N >> M >> A; set<int> st, st2; vector<int> v; for (int i=0; i<N-1; i++){ cin >> A; st.insert(A); } st2 = st; while(!st.empty()){ x = *st.begin(); for (int i=x; i<=M; i+=x){ if (!st2.count(i)){ cout << -1 << endl; return 0; } st.erase(i); } v.push_back(x); } cout << v.size() << endl; for (auto x : v) cout << x << " "; cout << endl; return 0; }