結果
問題 |
No.910 素数部分列
|
ユーザー |
|
提出日時 | 2019-10-19 10:19:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 1,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 1,001 ms |
コンパイル使用メモリ | 66,180 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 21:31:10 |
合計ジャッジ時間 | 2,655 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
ソースコード
#include<iostream> using namespace std; int main(){ int n; string s; cin >> n >> s; int ans = 0, one = 0, nine = 0; for(char c : s){ if(c == '1'){ one++; }else if(c == '9'){ if(one){ one--; ans++; }else{ nine++; } }else{ ans++; } } ans += min(nine/2, one) + (one-min(nine/2,one))/2; cout << ans << endl; return 0; }