結果

問題 No.24 数当てゲーム
ユーザー itok217
提出日時 2017-05-10 21:42:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 624 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 66,588 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 07:11:50
合計ジャッジ時間 1,412 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;

int main() {
  vector<int> v(10, 1);
  vector<int> a(4);
  int N;
  string s;
  cin >> N;
  while (N--) {
    for (auto &x : a) {
      cin >> x;
    }
    cin >> s;
    if (s == "YES") {
      for (auto &x : a) {
        if (v[x] != 0) {
          v[x]++;
        }
      }
    } else {
      for (auto &x : a) {
        v[x] = 0;
      }
    }
  }
  int max = 0;
  int ans = -1;
  for (int i = 0; i < 10; i++) {
    if (v[i] > max) {
      max = v[i];
      ans = i;
    }
  }
  cout << ans << endl;
}
0