結果
問題 |
No.3288 Sloppy Land Grading
|
ユーザー |
|
提出日時 | 2025-10-04 15:39:48 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 370 ms / 2,000 ms |
コード長 | 686 bytes |
コンパイル時間 | 3,374 ms |
コンパイル使用メモリ | 276,024 KB |
実行使用メモリ | 7,720 KB |
最終ジャッジ日時 | 2025-10-04 15:39:58 |
合計ジャッジ時間 | 8,724 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; ll A,B,C,x,y,z; ll ternary_search(auto f){ ll high = 110000; ll low = 1; while(1){ ll m1 = low + (high-low)/3; ll m2 = low + (high-low)*2/3; if(f(m1)>f(m2))low = m1; else high = m2; if(high-low<=2)return min({f(low),f(low+1),f(high)}); } } int main(){ ll TESTCASES; cin >> TESTCASES; while(TESTCASES--){ cin >> A >> B >> C >> x >> y >> z; auto f = [&](ll t)-> ll { return abs(A-t)*x + abs(B-t)*y + abs(C-t)*z; }; cout << ternary_search(f) << '\n'; } flush(cout); }