結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-18 21:43:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 1,000 ms |
| コード長 | 336 bytes |
| コンパイル時間 | 501 ms |
| コンパイル使用メモリ | 64,936 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-25 21:22:10 |
| 合計ジャッジ時間 | 1,964 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
コンパイルメッセージ
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')
{
c1++;
}
else if(s[i]=='9')
{
if(c1>=1)
{
c1-=1;
ans++;
}
else c9++;
}
else ans++;
}
int t=min(c9/2,c1);
ans+=t;
c1-=t;
ans+=c1/2;
cout<<ans<<endl;
}