結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
![]() |
提出日時 | 2017-01-23 01:13:03 |
言語 | C90 (gcc 12.3.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 523 bytes |
コンパイル時間 | 398 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 05:45:00 |
合計ジャッジ時間 | 4,963 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 1 RE * 3 |
other | AC * 4 WA * 3 RE * 21 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:19:8: warning: passing argument 1 of ‘sort’ makes pointer from integer without a cast [-Wint-conversion] 19 | sort(r,g,b); | ^ | | | int main.c:3:16: note: expected ‘int *’ but argument is of type ‘int’ 3 | void sort(int* a,int* b,int* c){ | ~~~~~^ main.c:19:10: warning: passing argument 2 of ‘sort’ makes pointer from integer without a cast [-Wint-conversion] 19 | sort(r,g,b); | ^ | | | int main.c:3:23: note: expected ‘int *’ but argument is of type ‘int’ 3 | void sort(int* a,int* b,int* c){ | ~~~~~^ main.c:19:12: warning: passing argument 3 of ‘sort’ makes pointer from integer without a cast [-Wint-conversion] 19 | sort(r,g,b); | ^ | | | int main.c:3:30: note: expected ‘int *’ but argument is of type ‘int’ 3 | void sort(int* a,int* b,int* c){ | ~~~~~^ main.c:18:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 18 | scanf("%d %d %d",&r,&g,&b); | ^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> #include<string.h> void sort(int* a,int* b,int* c){ int temp; if(a>b){ temp=*a; *a=*b; *b=temp; } if(b>c){ temp=*b; *b=*c; *c=temp; } } int main(void){ int r,g,b,n=0; scanf("%d %d %d",&r,&g,&b); sort(r,g,b); if(r==0){ printf("0\n"); return 0; } n=r; g-=r; b-=r; r=0; while(g>=2){ g-=2; b--; n++; } if(g==1){ if(b>2){ b-=2; n++; } } while(b>4){ b-=4; n++; } printf("%d\n",n ); return 0; }