結果
| 問題 |
No.910 素数部分列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-10-19 13:14:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 1,000 ms |
| コード長 | 612 bytes |
| コンパイル時間 | 382 ms |
| コンパイル使用メモリ | 27,264 KB |
| 最終ジャッジ日時 | 2025-01-08 00:01:09 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 50 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:17: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
4 | int n; scanf("%d\n", &n);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <stdio.h>
int main(void){
int n; scanf("%d\n", &n);
int res = 0, one = 0, nine = 0;
for(int i = 0; i < n; ++i){
switch(getchar()){
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;
}