QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#672268 | #9408. Hero of the Kingdom | REN_REN# | TL | 0ms | 3548kb | C++20 | 1.1kb | 2024-10-24 16:14:08 | 2024-10-24 16:14:08 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
using i128 = __int128;
int n, k;
const int mod = 998244353;
int p, a, b, q, c, d, m, t;
void solve(){
cin >> p >> a >> b;
cin >> q >> c >> d;
cin >> m >> t;
a += c, b += d;
while(1) {
int i = min(m / p, (t - b) / a);
if(i <= 0) break;
int tmaxc = t / (a * i + b);
int gain = tmaxc * i * (q - p);
if(m + gain >= p * (i + 1)) {
int nd = p * (i + 1) - m;
int ndx = (nd + (q - p) - 1) / (q - p);
int ndc = (ndx + i - 1) / i;
int ndt = a * ndc * i + b * ndc;
// cout << i << ' ' << nd << ' ' << ndx << ' ' << ndc << ' ' << ndt << ' ';
t -= ndt;
m += ndc * (q - p) * i;
// cout << t << ' ' << m << endl;
} else {
m += gain;
break;
}
}
cout << m << '\n';
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t = 1;
cin >> t;
while(t --){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3548kb
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
Time Limit Exceeded
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...