結果
| 問題 |
No.91 赤、緑、青の石
|
| ユーザー |
184
|
| 提出日時 | 2014-12-09 09:06:27 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 5,000 ms |
| コード長 | 698 bytes |
| コンパイル時間 | 327 ms |
| コンパイル使用メモリ | 41,676 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-24 06:45:44 |
| 合計ジャッジ時間 | 1,386 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:13:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
13 | int rgb[3];scanf("%d%d%d",&rgb[0],&rgb[1],&rgb[2]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
using namespace std;
//namaega184
int main(){
int rgb[3];scanf("%d%d%d",&rgb[0],&rgb[1],&rgb[2]);
int ans;
sort(rgb,rgb+3);ans=rgb[0];
for(int i=1;i<3;i++)rgb[i]-=rgb[0];
rgb[2]-=rgb[1];
if(rgb[1]==0){
ans+=rgb[2]/5;
}
else{
if((rgb[2]/2)<rgb[1]){
rgb[1]=rgb[1]-rgb[2]/2;
if(rgb[1]<3)rgb[1]=0;
ans+=rgb[2]/2+(rgb[1]>2?(rgb[1]/2-((int)(rgb[1]%2+rgb[2]%2==0)+rgb[1]/2%2)/2+((int)(rgb[1]%2+rgb[2]==2)+rgb[1]/2%2)/2):0);
}
else{
ans+=rgb[1];
rgb[2]-=rgb[1]*2;
ans+=rgb[2]/5;
}
}
printf("%d\n",ans);
return 0;
}
184