結果
問題 |
No.3288 Sloppy Land Grading
|
ユーザー |
|
提出日時 | 2025-10-03 22:30:21 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 724 bytes |
コンパイル時間 | 2,489 ms |
コンパイル使用メモリ | 276,084 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 22:30:33 |
合計ジャッジ時間 | 6,817 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 8 WA * 8 |
ソースコード
#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))return f(m1); 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); }