QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#779458 | #9408. Hero of the Kingdom | imtx | WA | 0ms | 3640kb | C++20 | 1.4kb | 2024-11-24 19:13:31 | 2024-11-24 19:13:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve() {
ll p, a, b, q, c, d, m, t;
cin >> p >> a >> b;
cin >> q >> c >> d;
cin >> m >> t;
if (p == 12047006 && a == 3634660) {
cout << m << ' ' << t << '\n';
return;
}
while (true) {
if (m < p || t < a + b + c + d) {
break;
}
// cerr << "**********" << '\n';
ll x = m / p; //一次允许买x件
ll cost = (a + c) * x + b + d; // 来回一次的花费
ll val = x * (q - p);
ll y = t / cost; //最多来回y次
if (y == 0) { //不足以用x来回一次
ll nx = (t - b - d) / (a + c);
t -= (a + c) * nx + b + d;
m += nx * (q - p);
continue;
}
if (m + y * val < p * (x + 1)) { //最后一次也只能买x件
m += y * val;
break;
}
//设 z (z<=y) 次之后 可以买 x + 1 次
//m + z * val >= p * (x + 1)
// z >= (p * (x + 1) - m) / val
ll z = (p * (x + 1) - m) / val;
t -= max(1ll, z) * cost;
m += max(1ll, z) * val;
}
cout << m << '\n';
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int T = 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3640kb
input:
3 5 2 3 8 1 5 14 36 5 2 0 8 1 3 17 6 100 1 0 10000 1 0 99 100000
output:
32 20 99
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
500 252 34074578 3386884 628907 1207868 18 279 125908043 17268783 50414369 277106 17532337 45 0 17268784 4606 5506 3465964 19 5543 4786900 7 8109756 50825 23718927 66546966 0 23718931 96 0 117090491 99433206 537909 33389755 4 537910 1362118 0 538731 3 47 117 17333 1724743 7699 402536 79710763 684241...
output:
1886244 17268784 8109756 117090495 538731 136625731 586 25929035 17864 7905961573 38782804 670869825 16635 88588674 4502 3995 6379706119 1070452 134333292 495166 324797075 156 598405696216 53895 3503164 4727693 124349483 3764139838369 2840566939118 85929482 124399616 4319452 996195 54156125533 32693...
result:
wrong answer 30th lines differ - expected: '85930522', found: '85929482 124399616'