結果
| 問題 | No.3681 心の沸騰石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-05 15:38:39 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| + 333µs | |
| コード長 | 1,562 bytes |
| 記録 | |
| コンパイル時間 | 2,908 ms |
| コンパイル使用メモリ | 350,416 KB |
| 実行使用メモリ | 9,780 KB |
| 最終ジャッジ日時 | 2026-09-05 15:38:50 |
| 合計ジャッジ時間 | 3,620 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
template <typename K, typename V>
using umap = unordered_map<K, V>;
#define rep(i, n) for (int i = 0; i < n;i++)
#define rep1(i, n) for (int i = 1; i <= n;i++)
#define rrep(i, n) for (int i = n - 1; i >= 0;i--)
#define rrep1(i, n) for (int i = n; i >= 1;i--)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define INF 1LL << 60
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ll r, p, q, a, b, c, d;
cin >> r >> p >> q >> a >> b >> c >> d;
ll ans = 0;
auto check = [&](ll x) {// x人のルーマニア人を錬成できるか?
if (x * p > r) {
return false;
}
ll res = min({a, b, c});
if (res >= x) {
return true;
}
ll A = a - res;
ll B = b - res;
ll C = c - res;
// 残りでremain人のルーマニア人を錬成できるか?
ll remain = x - res;
ll need = max(0LL, remain - A) + max(0LL, remain - B) + max(0LL, remain - C);
if (need > d) {
return false;
}
if (need * q + x * p > r) {
return false;
}
return true;
};
ll ok = 0;
ll ng = a + b + c + d;
while (ng - ok > 1) {
ll mid = (ok + ng) / 2;
if (check(mid)) {
ok = mid;
} else {
ng = mid;
}
}
cout << ok << endl;
}