結果
問題 | No.2806 Cornflake Man |
ユーザー |
![]() |
提出日時 | 2024-07-04 23:50:28 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 150 ms / 2,000 ms |
コード長 | 536 bytes |
コンパイル時間 | 2,485 ms |
コンパイル使用メモリ | 207,868 KB |
最終ジャッジ日時 | 2025-02-22 02:05:07 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define int long longsigned main(){int N,M;cin>>N>>M;vector<int> A(N);for(int i=0;i<N;i++) cin>>A[i];sort(A.begin(),A.end());vector<bool> P(N);unordered_map<int,int> m;for(int i=0;i<N;i++) m[A[i]] = i;vector<int> s = {};for(int i=1;i<N;i++)if(!P[i]){P[i] = true;s.push_back(A[i]);for(int j=A[i];j<=M;j+=A[i]){if(!m.count(j)){cout<<-1<<endl;return 0;}P[m[j]] = true;}}cout<<s.size()<<endl;for(int x:s) cout<<x<<' ';cout<<endl;}