結果
| 問題 | No.3681 心の沸騰石 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-10 01:41:48 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 458µs | |
| コード長 | 958 bytes |
| 記録 | |
| コンパイル時間 | 2,994 ms |
| コンパイル使用メモリ | 350,684 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-10 01:41:53 |
| 合計ジャッジ時間 | 4,749 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 13 |
ソースコード
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
using ll = long long;
void solve() {
ll R, P, Q;
cin >> R >> P >> Q;
vector<ll> D(4);
for (int i = 0; i < 4; i++) cin >> D[i];
auto judge = [&](ll k) -> bool {
ll rem = D[3];
ll need = 0;
for (int i = 0; i < 3; i++) {
if (D[i] >= k) rem += D[i] - k;
else need += k - D[i];
}
if (rem < need) return false;
ll sum = 0;
sum += need * Q;
sum += k * P;
return sum <= R;
};
ll ok = 0;
ll ng = R + 1; // [ok, ng)
while (ng - ok > 1) {
ll mid = (ok + ng) / 2;
if (judge(mid)) {
ok = mid;
} else {
ng = mid;
}
}
cout << ok << endl;
return;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll T = 1;
// cin >> T;
while (T--) {
solve();
}
return 0;
}