結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-18 21:33:22 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 348 bytes |
| コンパイル時間 | 743 ms |
| コンパイル使用メモリ | 64,564 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-25 15:05:07 |
| 合計ジャッジ時間 | 2,330 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 22 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
6 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
string s;
int N;
int ans;
main()
{
cin>>N>>s;
int c1=0,c9=0;
for(int i=0;i<N;i++)
{
if(s[i]=='1')
{
if(c9>=2)
{
c9-=2;
ans++;
}
else c1++;
}
else if(s[i]=='9')
{
if(c1>=1)
{
c1-=1;
ans++;
}
else c9++;
}
else ans++;
}
ans+=c1/2;
cout<<ans<<endl;
}