結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
bal4u
|
| 提出日時 | 2019-11-16 15:25:38 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 5 ms / 1,000 ms |
| コード長 | 904 bytes |
| コンパイル時間 | 181 ms |
| コンパイル使用メモリ | 30,208 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-24 16:10:46 |
| 合計ジャッジ時間 | 1,612 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
ソースコード
// yuki 915 Plus Or Multiple Operation
// 2019.11.16 bal4u
#include <stdio.h>
#include <ctype.h>
int getchar_unlocked(void);
#define gc() getchar_unlocked()
int in() { // 非負整数の入力
int n = 0; int c;
do c = gc(); while (isspace(c));
do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
return n;
}
int ans;
void ins(char *s) { // 特殊:文字列の入力
char c;
while ((c = gc()) > ' ') {
if (c == '3' || c == '5' || c == '7') ans++;
else *s++ = c;
}
*s = 0;
}
char S[200005];
int main()
{
int n1, n9, t;
char *p;
in(), ins(S);
n1 = n9 = 0, p = S;
while (*p) {
if (*p == '1') n1++;
else {
if (n1) ans++, n1--;
else n9++;
}
p++;
}
if (n1 <= n9/2) ans += n1;
else {
ans += n9/2, n1 -= n9/2;
ans += n1/2;
}
printf("%d\n", ans);
return 0;
}
bal4u