結果
問題 | No.910 素数部分列 |
ユーザー |
|
提出日時 | 2019-10-19 13:09:49 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 1,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 190 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 01:49:55 |
合計ジャッジ時間 | 2,054 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 50 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:11:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | int n; scanf("%d%s", &n, str); | ~~~~~^~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> #define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i)) #define REP(i, n) FOR(i, 0, n) constexpr int MAX_SIZE = 2e5 + 10; char str[MAX_SIZE]; int main(void){ int n; scanf("%d%s", &n, str); int res = 0, one = 0, nine = 0; REP(i, n){ switch(str[i]){ case '1': one++; break; case '3': case '5': case '7': res++; break; case '9': if(one >= 1){one--; res++;} else nine++; break; } } int d = (one > nine / 2) ? nine / 2 : one; res += d; one -= d; res += one / 2; printf("%d\n", res); return 0; }