結果
問題 |
No.91 赤、緑、青の石
|
ユーザー |
![]() |
提出日時 | 2015-07-16 23:07:17 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 73 ms / 5,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 739 ms |
コンパイル使用メモリ | 23,168 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 06:50:24 |
合計ジャッジ時間 | 2,380 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:27:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 27 | scanf("%d %d %d", &rgb[0], &rgb[1], &rgb[2]); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <math.h> #include <string.h> #include <stdio.h> int min(int a, int b){ if(a<b){return a;} return b; } void sortRGB(int *rgb){ int i,j; for(i=0;i<3;i++){ for(j=i+1;j<3;j++){ if(rgb[i] < rgb[j]){ int tmp = rgb[i]; rgb[i] = rgb[j]; rgb[j] = tmp; } } } return; } int main(void){ int ans = 0; int rgb[3]; scanf("%d %d %d", &rgb[0], &rgb[1], &rgb[2]); sortRGB(rgb); while(1){ ans += rgb[2]; rgb[0] -= rgb[2]; rgb[1] -= rgb[2]; rgb[2] -= rgb[2]; sortRGB(rgb); if(rgb[1] == 0){ int tmp = (rgb[0]/5); rgb[1] += tmp; rgb[2] += tmp; rgb[0] -= tmp*2*2; }else{ int tmp = 0; if(rgb[0]>2){tmp=1;} rgb[2] += tmp; rgb[0] -= tmp*2; } sortRGB(rgb); if(rgb[2] == 0){ break; } } printf("%d\n", ans); return 0; }