結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
otamay6
|
| 提出日時 | 2019-10-19 11:49:27 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 621 bytes |
| コンパイル時間 | 1,575 ms |
| コンパイル使用メモリ | 168,456 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-27 00:01:28 |
| 合計ジャッジ時間 | 3,631 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
int main(){
int N;cin>>N;
string S;cin>>S;
int iti=0,kyu=0;
int ans=0;
REP(i,N){
if(S[i]=='1'){
iti++;
}
else if(S[i]=='9'){
if(iti>0){
ans++;
iti--;
}
else kyu++;
}
else ans++;
}
if(kyu>=2*iti) ans+=iti;
else ans+=kyu/2+(iti-kyu/2)/2;
cout<<ans<<endl;
}
otamay6