結果

問題 No.91 赤、緑、青の石
ユーザー takatowin
提出日時 2017-01-23 01:14:20
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 260 ms
コンパイル使用メモリ 21,376 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 05:45:13
合計ジャッジ時間 1,451 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other AC * 4 WA * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
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);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
}

0