結果
| 問題 |
No.91 赤、緑、青の石
|
| ユーザー |
goodbaton
|
| 提出日時 | 2015-08-04 22:04:19 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 970 bytes |
| コンパイル時間 | 547 ms |
| コンパイル使用メモリ | 72,068 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 01:19:47 |
| 合計ジャッジ時間 | 1,592 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 24 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:27:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
27 | scanf("%d%d%d",&R,&G,&B);
| ~~~~~^~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cstring>
typedef long long ll;
using namespace std;
#define mod 1000000009
#define INF 10000000
#define LLINF 2000000000000000000LL
#define SIZE 101
int main(){
int R,G,B,ans=0;
scanf("%d%d%d",&R,&G,&B);
ans+=min(R,min(G,B));
R-=ans;
G-=ans;
B-=ans;
int l=0,r=max(R,max(G,B)),mid,rest;
while(l<r){
mid = (l+r+1)/2;
rest=0;
rest+=max(R-mid,0);
rest+=max(G-mid,0);
rest+=max(B-mid,0);
rest/=2;
rest-=max(mid-R,0);
rest-=max(mid-G,0);
rest-=max(mid-B,0);
if(rest>=0){
l=mid;
}else{
r=mid-1;
}
}
printf("%d\n",ans+l);
return 0;
}
goodbaton