結果
問題 |
No.910 素数部分列
|
ユーザー |
|
提出日時 | 2019-10-20 04:49:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 730 bytes |
コンパイル時間 | 2,630 ms |
コンパイル使用メモリ | 191,844 KB |
最終ジャッジ日時 | 2025-01-08 00:03:28 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 38 |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; string s; cin >> s; int ans = 0; int cnt[10] = {}; for (char c : s) { int x = c - '0'; if (x == 9) { if (cnt[5]) { ans++; cnt[5]--; } else if (cnt[7]) { ans++; cnt[7]--; } else if (cnt[1]) { ans++; cnt[1]--; } } if (x == 7) { cnt[7]++; } if (x == 5) { cnt[5]++; } if (x == 3) { cnt[3]++; } if (x == 1) { cnt[1]++; } } ans += cnt[1] / 2; ans += cnt[3]; ans += cnt[5]; ans += cnt[7]; cout << ans << '\n'; return 0; }