結果
| 問題 | No.3681 心の沸騰石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 14:05:49 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 461µs | |
| コード長 | 2,724 bytes |
| 記録 | |
| コンパイル時間 | 5,088 ms |
| コンパイル使用メモリ | 387,280 KB |
| 実行使用メモリ | 9,728 KB |
| 最終ジャッジ日時 | 2026-09-05 14:07:10 |
| 合計ジャッジ時間 | 6,557 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge6_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using mint = modint998244353;
// using mint = modint1000000007;
constexpr ll INF = (1LL << 60);
constexpr int INF32 = (1 << 30);
template<typename T> using vc = vector<T>;
template<typename T> using vv = vector<vector<T>>;
using vi = vc<int>;
using vvi = vv<int>;
using vl = vc<ll>;
using vvl = vv<ll>;
using vs = vc<string>;
using vvs = vv<string>;
using vb = vc<bool>;
using vvb = vv<bool>;
using vmint = vc<mint>;
using vvmint = vv<mint>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define drep(i,n) for(ll i=(ll)(n)-1; i>=0; i--)
#define rrep(i,n) for(ll i=1; i<=(ll)(n); i++)
#define nfor(i,a,b) for(ll i=(ll)(a); i<(ll)(b); i++)
#define dfor(i,a,b) for(ll i=(ll)(a)-1; i>=(ll)(b); i--)
#define nall(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
template<class T>
istream& operator>>(istream& is, vector<T>& v) {
for (auto& x : v) is >> x;
return is;
}
template<class T, class U>
istream& operator>>(istream& is, pair<T,U>& p) {
return is >> p.first >> p.second;
}
template<class T>
bool chmax(T& a, const T& b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template<class T>
bool chmin(T& a, const T& b) {
if (a > b) {
a = b;
return true;
}
return false;
}
void YES() { cout << "Yes\n"; }
void NO() { cout << "No\n"; }
void yn(bool ok) {
cout << (ok ? "Yes" : "No") << '\n';
}
template<class T>
void print(const vector<T>& v) {
for (int i = 0; i < (int)v.size(); i++) {
if (i) cout << ' ';
cout << v[i];
}
cout << '\n';
}
template<class T>
void print(const vector<vector<T>>& v) {
for (const auto& row : v) {
print(row);
}
}
void print(ld x) {
cout << fixed << setprecision(20) << x << '\n';
}
ll R, P, Q, A, B, C, D;
template<class F>
ll binary_search_last_true(ll ok, ll ng, F is_ok) {
// is_ok(ok) == true
// is_ok(ng) == false
while (abs((__int128)ok - ng) > 1) {
ll mid = (ll)((__int128)ok + ((__int128)ng - ok) / 2);
if (is_ok(mid)) ok = mid;
else ng = mid;
}
return ok;
}
bool is_ok(ll K) {
ll need = 0;
need += max(0LL,K-A) + max(0LL,K-B) + max(0LL,K-C);
if(need>D) return false;
ll cost = 0;
cost += K * P;
cost += need * Q;
if(cost>R) return false;
return true;
}
int main() {
cin >> R >> P >> Q >> A >> B >> C >> D;
ll mx = max(max(A+D,B+D),C+D);
ll ans = binary_search_last_true(0,mx+1,is_ok);
cout << ans << endl;
}