結果

問題 No.112 ややこしい鶴亀算
ユーザー k
提出日時 2014-12-24 14:51:10
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 828 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 70,880 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 04:54:19
合計ジャッジ時間 1,464 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>

using namespace std;

int main() {
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  int x = -1;
  for (int i = 0; i < n-1; i++) {
    if (a[i] == a[i+1]) continue;
    if (a[i] < a[i+1]) {
      x = a[i]+4;
      break;
    }else {
      x = a[i]+2;
      break;
    }
  }

  if (x == -1) {
    if ((n-1)*2 == a[0]) {
      x = a[0]+2;
    }else {
      x = a[0]+4;
    }
  }
  int kame = 0, turu = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == x-2) {
      turu++;
    }else {
      kame++;
    }
  }

  cout << turu << " " << kame << endl;
}
0