結果
問題 |
No.112 ややこしい鶴亀算
|
ユーザー |
![]() |
提出日時 | 2015-09-05 21:24:15 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 686 bytes |
コンパイル時間 | 393 ms |
コンパイル使用メモリ | 44,032 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-19 04:12:58 |
合計ジャッジ時間 | 1,045 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 1 |
other | AC * 9 WA * 14 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:12:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | scanf("%d", &animals[i]); | ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main(){ int n, a, b; scanf("%d", &n); vector<int> animals(n); for(int i = 0; i < n; i++){ scanf("%d", &animals[i]); } sort(animals.begin(), animals.end()); if(animals[0] == animals[n - 1]){ a = (animals[0] / (n - 1) == 2) * n; b = (animals[0] / (n - 1) == 4) * n; } else{ n--; a = upper_bound(animals.begin(), animals.end(), animals[0]) - lower_bound(animals.begin(), animals.end(), animals[n]); b = upper_bound(animals.begin(), animals.end(), animals[n]) - lower_bound(animals.begin(), animals.end(), animals[0]); } printf("%d %d\n", a, b); return 0; }