結果

問題 No.804 野菜が苦手
コンテスト
ユーザー peroon
提出日時 2019-04-21 13:49:54
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 842 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,312 ms
コンパイル使用メモリ 162,392 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-12-06 14:49:18
合計ジャッジ時間 2,230 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll ans = 0;
    FOR(a, 1, A+1){
        ll need_meat = a * C;
        if(need_meat > B){
            break;
        }else{
            ll eat_sum = a + need_meat;
            if(eat_sum > D){
                break;
            }else{
                ans = a;
            }
        }
    }

    p(ans);
    
    return 0;
}
0