結果
| 問題 | No.910 素数部分列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-11-25 01:00:40 |
| 言語 | C++23(gcc16) (gcc 16.2.0 + boost 1.92.0 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 752 bytes |
| 記録 | |
| コンパイル時間 | 3,483 ms |
| コンパイル使用メモリ | 180,560 KB |
| 実行使用メモリ | 9,924 KB |
| 最終ジャッジ日時 | 2026-11-25 01:00:48 |
| 合計ジャッジ時間 | 4,822 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 WA * 30 |
ソースコード
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
string s;
int n, ans, rem1;
vector<int> pos1, pos9;
int main() {
scanf("%d", &n);
for (int i = 0, x; i < n; ++i) {
scanf(" %1d", &x);
if (x == 3 || x == 5 || x == 7) {
++ans;
} else s += '0' + x;
}
n = s.size();
s = ' ' + s;
for (int i = 1; i <= n; ++i) {
if (s[i] == '1') pos1.push_back(i);
else pos9.push_back(i);
}
auto it = pos9.begin();
for (auto i : pos1) {
auto pos = lower_bound(it, pos9.end(), i);
if (pos < pos9.end()) {
++ans;
it = next(pos);
} else ++rem1;
}
printf("%d\n", ans + rem1 / 2);
return 0;
}