結果
| 問題 |
No.91 赤、緑、青の石
|
| コンテスト | |
| ユーザー |
takatowin
|
| 提出日時 | 2017-01-23 01:38:07 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 604 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 21,376 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-23 05:45:14 |
| 合計ジャッジ時間 | 1,119 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | AC * 14 WA * 14 |
コンパイルメッセージ
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);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#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,i=0,temp;
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;
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;
}
takatowin