結果

問題 No.3681 心の沸騰石
コンテスト
ユーザー sorachandu
提出日時 2026-09-05 14:19:54
言語 C++23
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 392µs
コード長 979 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,068 ms
コンパイル使用メモリ 330,820 KB
実行使用メモリ 6,272 KB
最終ジャッジ日時 2026-09-05 14:20:13
合計ジャッジ時間 3,879 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge7_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(nullptr)->ios::sync_with_stdio(false);
    /*//------------------------
    決め打ち二分探索がききそうに思うが
    x人作るとしたとき、赤黄青のうちxに満たないとこだけ補強
    そうですね
    *///------------------------
    long long R,P,Q,A,B,C,D;
    cin>>R>>P>>Q>>A>>B>>C>>D;
    auto judge=[&](long long x){
        long long cost{};
        long long rem=D;
        long long cnt{};
        cost+=max(x-A,0ll)*Q;
        cnt+=max(x-A,0ll);
        rem+=max(A-x,0ll);
        cost+=max(x-B,0ll)*Q;
        cnt+=max(x-B,0ll);
        rem+=max(B-x,0ll);
        cost+=max(x-C,0ll)*Q;
        cnt+=max(x-C,0ll);
        rem+=max(C-x,0ll);
        return (cnt<=rem and cost+(x*P)<=R);
    };
    long long ok=0,ng=1<<30;
    while(abs(ok-ng)>1){
        long long mid=midpoint(ok,ng);
        if(judge(mid)) ok=mid;
        else ng=mid;
    }
    cout<<ok<<"\n";
}
0