結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
totori_nyaa
|
| 提出日時 | 2019-10-18 21:46:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,005 bytes |
| コンパイル時間 | 1,614 ms |
| コンパイル使用メモリ | 168,212 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-25 15:28:51 |
| 合計ジャッジ時間 | 2,945 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 22 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool isprime(long long int val) {
if (val <= 1)return false;
for (long long int i = 2; i*i <= val; i++) {
if (val%i == 0LL)return false;
}
return true;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
int n;
string s;
cin>>n>>s;
ll ans = 0;
string num = "13579";
ll cnt[5]={};
for(int i=0;i<n;i++){
for(int j=0;j<5;j++){
if(s[i]==num[j]){
cnt[j]++;
}
}
}
ans += cnt[1] + cnt[2] + cnt[3];
ll t=0;
ll q=0;
for(int i=0;i<n;i++){
if(s[i]=='1'){
if(q>=2){
q-=2;
ans++;
}
else t++;
}
if(s[i]=='9' && t){
ans++;
t--;
}
else if(s[i]=='9'){
q++;
}
}
ans += t/2;
cout << ans << endl;
}
totori_nyaa