結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2019-10-18 22:09:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 759 bytes |
| コンパイル時間 | 1,811 ms |
| コンパイル使用メモリ | 159,796 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 21:31:33 |
| 合計ジャッジ時間 | 3,465 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
int main(){
ll n;
cin>>n;
string s;
cin>>s;
ll cnt9=0;
ll cnt1=0;
ll ans=0;
reverse(all(s));
rep(i,n){
if(s[i]=='9'){
cnt9++;
}
else if(s[i]=='1'){
if(cnt9){
ans++;
cnt9--;
}else{
cnt1++;
}
}else{
ans++;
}
}
ans+=min(cnt9/2,cnt1);
cnt1-=min(cnt9/2,cnt1);
ans+=cnt1/2;
cout<<ans<<endl;
}
auaua