結果

問題 No.112 ややこしい鶴亀算
コンテスト
ユーザー stone_725
提出日時 2015-09-05 21:24:15
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 686 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 355 ms
コンパイル使用メモリ 68,976 KB
実行使用メモリ 76,908 KB
最終ジャッジ日時 2026-04-02 14:05:12
合計ジャッジ時間 1,108 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1
other AC * 9 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0