結果

問題 No.910 素数部分列
ユーザー takumi152takumi152
提出日時 2019-10-18 21:49:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 73,108 KB
最終ジャッジ日時 2025-01-07 22:48:45
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cstdlib>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  string s;
  cin >> s;

  int c1 = 0, c3 = 0, c5 = 0, c7 = 0;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    char buf = s[i];
    switch (buf) {
      case '1':
        c1++;
        break;
      case '3':
        c3++;
        break;
      case '5':
        c5++;
        break;
      case '7':
        c7++;
        break;
      case '9':
        if (c1 > 0) {
          ans++;
          c1--;
        }
        break;
    }
  }
  ans += c1 / 2 + c3 + c5 + c7;

  cout << ans << endl;

  return 0;
}
0