結果
| 問題 | No.91 赤、緑、青の石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-06-17 18:12:09 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 773 bytes |
| 記録 | |
| コンパイル時間 | 604 ms |
| コンパイル使用メモリ | 51,804 KB |
| 最終ジャッジ日時 | 2024-11-14 19:04:18 |
| 合計ジャッジ時間 | 1,049 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:3: error: ‘vector’ was not declared in this scope
9 | vector<int> v(3);
| ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
2 | #include <algorithm>
+++ |+#include <vector>
3 | using namespace std;
main.cpp:9:10: error: expected primary-expression before ‘int’
9 | vector<int> v(3);
| ^~~
main.cpp:10:40: error: ‘v’ was not declared in this scope
10 | for(int i : range(3)) { scanf("%d", &v[i]); }
| ^
main.cpp:11:8: error: ‘v’ was not declared in this scope
11 | sort(v.begin(), v.end());
| ^
main.cpp:13:9: error: ‘hi’ was not declared in this scope
13 | while(hi - lo > 1) {
| ^~
main.cpp:20:7: error: ‘amaru’ was not declared in this scope
20 | amaru += (v[1] - md) / 2;
| ^~~~~
main.cpp:22:8: error: ‘amaru’ was not declared in this scope
22 | if(amaru >= taran) {
| ^~~~~
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};
int main(void) {
vector<int> v(3);
for(int i : range(3)) { scanf("%d", &v[i]); }
sort(v.begin(), v.end());
int lo = v[0], hi = v[2];
while(hi - lo > 1) {
int md = (lo + hi) / 2;
int taran = md - v[0],
amaru = (v[2] - md) / 2;
if(md > v[1]) {
taran += md - v[1];
} else {
amaru += (v[1] - md) / 2;
}
if(amaru >= taran) {
lo = md;
} else {
hi = md;
}
}
printf("%d\n", lo);
return 0;
}