結果
問題 |
No.3288 Sloppy Land Grading
|
ユーザー |
|
提出日時 | 2025-10-03 22:00:18 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 338 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 2,680 ms |
コンパイル使用メモリ | 276,204 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-10-03 22:00:27 |
合計ジャッジ時間 | 7,290 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 16 |
ソースコード
#include <bits/stdc++.h> #define int long long using namespace std; void solve(){ int a,b,c,x,y,z;cin>>a>>b>>c>>x>>y>>z; int l=0,r=1e5+10; auto calc_score=[&](int n)->int { int ret=0; ret+=x*(abs(n-a)); ret+=y*(abs(n-b)); ret+=z*(abs(n-c)); return ret; }; while(r-l>10){ int c1=(r+2*l)/3,c2=(2*r+l)/3; int lft=calc_score(c1),rht=calc_score(c2); if(lft>rht){ l=c1; }else{ r=c2; } } int ans=1e18; for(int x=l;x<=r;x++){ ans=min(ans,calc_score(x)); } cout<<ans<<"\n"; } signed main(){ int n;cin>>n; while(n--){ solve(); } }