結果
| 問題 |
No.91 赤、緑、青の石
|
| コンテスト | |
| ユーザー |
takatowin
|
| 提出日時 | 2017-01-23 20:31:56 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 672 bytes |
| コンパイル時間 | 280 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 07:44:01 |
| 合計ジャッジ時間 | 1,263 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 18 WA * 10 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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,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;
if(g==0 || r<2){
printf("%d\n",n );
return 0;
}
temp=(b-g)/2;
n+=temp;
b-=temp*3;
g-=temp;
while((g>=3 || b>=3) && b>0 && g>0){
if(b<=g){
n++;
g-=3;
b--;
}else{
n++;
g--;
b-=3;
}
}
printf("%d\n",n);
return 0;
}
takatowin