結果
| 問題 |
No.112 ややこしい鶴亀算
|
| コンテスト | |
| ユーザー |
stone_725
|
| 提出日時 | 2015-09-05 21:19:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 685 bytes |
| コンパイル時間 | 482 ms |
| コンパイル使用メモリ | 44,160 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-19 04:12:35 |
| 合計ジャッジ時間 | 1,225 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 11 WA * 12 |
コンパイルメッセージ
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{
a = upper_bound(animals.begin(), animals.end(), animals[0]) - lower_bound(animals.begin(), animals.end(), animals[0]);
b = upper_bound(animals.begin(), animals.end(), animals[n - 1]) - lower_bound(animals.begin(), animals.end(), animals[n - 1]);
}
printf("%d %d\n", a, b);
return 0;
}
stone_725