結果
問題 | No.91 赤、緑、青の石 |
ユーザー |
![]() |
提出日時 | 2016-03-22 23:41:50 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 558 bytes |
コンパイル時間 | 250 ms |
コンパイル使用メモリ | 23,040 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-24 06:57:03 |
合計ジャッジ時間 | 1,228 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 28 |
コンパイルメッセージ
main.cpp: In function ‘int main(int, char**)’: main.cpp:31:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 31 | scanf(" %d %d %d", &r, &g, &b); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <cstdio>int r, g, b;bool check(int x) {int pos = 0;int neg = 0;if (r >= x) pos += (r - x) / 2; else neg += x - r;if (g >= x) pos += (g - x) / 2; else neg += x - g;if (b >= x) pos += (b - x) / 2; else neg += x - b;return pos >= neg;}int solve() {int hi = 1e7 + 1;int lo = 0;while (hi - lo > 1) {int mi = (lo + hi) / 2;if (check(mi))lo = mi;elsehi = mi;}return lo;}int main(int argc, char *argv[]){scanf(" %d %d %d", &r, &g, &b);printf("%d\n", solve());return 0;}