結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
NOSS
|
| 提出日時 | 2019-10-18 21:51:15 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 630 bytes |
| コンパイル時間 | 1,687 ms |
| コンパイル使用メモリ | 166,348 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 15:34:10 |
| 合計ジャッジ時間 | 3,325 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, ans = 0;
string s;
cin >> n >> s;
int cnt1 = 0, cnt9 = 0;
for(int i=0;i<n;i++){
if(s[i] == '3' || s[i] == '5' || s[i] == '7') ans++;
else if(s[i] == '1'){
// 991
if(cnt9 > 1){
ans++;
cnt9 -= 2;
}
else cnt1++;
}
else{
// 19
if(cnt1 > 0){
ans++;
cnt1--;
}
else cnt9++;
}
}
// 11
ans += cnt1/2;
cout << ans << endl;
return 0;
}
NOSS