結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
hamuhei4869
|
| 提出日時 | 2019-10-18 21:49:34 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 783 bytes |
| コンパイル時間 | 1,503 ms |
| コンパイル使用メモリ | 159,792 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-25 15:31:26 |
| 合計ジャッジ時間 | 3,258 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
int main()
{
int N;
string S;
cin >> N;
cin >> S;
int ans = 0;
ans += count(S.begin(), S.end(), '7');
ans += count(S.begin(), S.end(), '3');
ans += count(S.begin(), S.end(), '5');
int one = 0;
int nine = 0;
int u = 0;
for(int i = 0;i < N;i++){
if(S[i] == '1' && nine < 2){
one++;
}
if(S[i] == '1' && nine >= 2){
nine-= 2;
u++;
}
if(S[i] == '9' && one != 0){
u++;
one--;
}
if(S[i] == '9' && one == 0){
nine++;
}
}
ans += u;
ans += (count(S.begin(), S.end(), '1') - u)/2;
cout<<ans<<endl;
}
hamuhei4869