結果
| 問題 |
No.1816 MUL-DIV Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-22 13:33:05 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 2,000 ms |
| コード長 | 525 bytes |
| コンパイル時間 | 608 ms |
| コンパイル使用メモリ | 44,032 KB |
| 最終ジャッジ日時 | 2025-01-27 14:47:42 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:15:37: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | for(int i = 0; i < N; ++i) scanf("%d", A + i);
| ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(){
int N;
scanf("%d", &N);
if(N > 1 && (N&1)){
printf("1\n");
return 0;
}
int A[N];
for(int i = 0; i < N; ++i) scanf("%d", A + i);
if(N == 1) printf("%d\n", A[0]);
else if(N == 2) printf("%lld\n", (ll)A[0]*A[1]);
else{
nth_element(A,A+2,A+N);
printf("%d\n", A[0] >= 1000000000/A[1] ? A[2] : min(A[0]*A[1], A[2]));
}
return 0;
}