結果
| 問題 |
No.2806 Cornflake Man
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-12 23:27:18 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,382 bytes |
| コンパイル時間 | 2,439 ms |
| コンパイル使用メモリ | 174,084 KB |
| 実行使用メモリ | 18,240 KB |
| 最終ジャッジ日時 | 2024-07-12 23:27:28 |
| 合計ジャッジ時間 | 8,584 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 15 |
ソースコード
#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 long
vector<int> printNonDivisibleElements(const vector<int>& arr) {
int n = arr.size();
vector<int> result;
for (int i = 0; i < n; ++i) {
bool isDivisible = false;
for (int j = 0; j < result.size(); ++j) {
if (arr[i] % result[j] == 0) {
isDivisible = true;
break;
}
}
if (!isDivisible) {
result.push_back(arr[i]);
}
}
return result;
}
void solve() {
int n, m;
cin >> n >> m;
vector<int> a(n);
for (auto &x : a) {
cin >> x;
}
sort(a.begin(), a.end());
reverse(a.begin(), a.end());
a.pop_back();
reverse(a.begin(), a.end());
auto p = printNonDivisibleElements(a);
debug(p);
for (auto &x : p) {
int c = 0;
for (int j = 0; j < a.size(); j++) {
c += (a[j] % x == 0);
}
if (c != (m / x)) {
cout << -1 << '\n'; return;
}
}
cout << p.size() << "\n";
for (auto &x : p) {
cout << x << " ";
}
}
signed main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#else
#endif
ios::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";
}