結果

問題 No.91 赤、緑、青の石
ユーザー takatowin
提出日時 2017-01-23 01:42:03
言語 C90
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 118 ms
コンパイル使用メモリ 21,248 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 05:45:17
合計ジャッジ時間 1,213 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:23:3: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |   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;
  }
  if(*a>*b){
    temp=*a;
    *a=*b;
    *b=temp;
  }
}
int main(void){
  int r,g,b,n=0,i=0,temp;
  scanf("%d %d %d",&r,&g,&b);
  sort(&r,&g,&b);
  printf("%d %d %d",r,g,b);

  n=r;
  g-=r;
  b-=r;
  temp=(b-g)/2;
  n+=temp;
  b-=temp*2;
  b-=temp;
  g-=temp;
  while((g>=3 || b>=3) && b>0 && g>0){
    if(i%2==0){
      n++;
      g-=3;
      b--;
    }else{
      n++;
      g--;
      b-=3;
    }
    i++;
  }
  printf("%d\n",n);
  return 0;
}

0