結果
| 問題 |
No.2806 Cornflake Man
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2024-07-15 15:35:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 967 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 43,904 KB |
| 最終ジャッジ日時 | 2025-02-23 15:46:54 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 10 TLE * 1 -- * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:29:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | scanf("%d%d", &n, &m);
| ~~~~~^~~~~~~~~~~~~~~~
main.cpp:30:36: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
30 | for (int i = 0; i < n; i++) scanf("%d", as + i);
| ~~~~~^~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 2806.cc: No.2806 Cornflake Man - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
using ll = long long;
/* global variables */
int as[MAX_N], bs[MAX_N], xs[MAX_N];
/* subroutines */
/* main */
int main() {
int n, m;
scanf("%d%d", &n, &m);
for (int i = 0; i < n; i++) scanf("%d", as + i);
sort(as + 1, as + n);
int k = 0;
for (int i = 1; i < n; i++) {
int c = 0;
for (int j = 0; j < k; j++)
if (as[i] % bs[j] == 0) {
if (bs[j] * xs[j] != as[i]) { puts("-1"); return 0; }
c++;
xs[j]++;
}
if (c == 0) {
if (m / as[i] > n) { puts("-1"); return 0; }
bs[k] = as[i], xs[k] = 2, k++;
}
}
for (int j = 0; j < k; j++)
if (bs[j] * xs[j] <= m) { puts("-1"); return 0; }
printf("%d\n", k);
for (int j = 0; j < k; j++)
printf("%d%c", bs[j], (j + 1 < k) ? ' ' : '\n');
return 0;
}
tnakao0123