QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#114759 | #5314. Zombie's Treasure Chest | PetroTarnavskyi# | AC ✓ | 57ms | 3712kb | C++17 | 1.0kb | 2023-06-23 15:20:57 | 2023-06-23 15:20:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int MAGIC = 1 << 18;
int main()
{
//ios::sync_with_stdio(false);
//cin.tie(0);
int tc;
scanf("%d", &tc);
FOR(t, 1, tc + 1) {
int n, s1, v1, s2, v2;
scanf("%d%d%d%d%d", &n, &s1, &v1, &s2, &v2);
LL ans = 0;
FOR(it, 0, 2) {
FOR(x, 0, MAGIC) {
if ((LL)s1 * x > n) {
break;
}
int y = (n - s1 * x) / s2;
ans = max(ans, (LL)v1 * x + (LL)v2 * y);
}
int xMx = n / s1;
FOR(x, max(0, xMx - MAGIC), xMx + 1) {
int y = (n - s1 * x) / s2;
ans = max(ans, (LL)v1 * x + (LL)v2 * y);
}
swap(s1, s2);
swap(v1, v2);
}
printf("Case #%d: %lld\n", t, ans);
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 57ms
memory: 3712kb
input:
200 2147483647 1 2147483647 2147483647 1 1000000000 30000 30000000 20000 19999999 999999999 10000 2147483647 9999 2137483647 999999999 100000 2147483647 99998 2137483647 2000000000 12345 54321 54321 200000 1000000 10000007 9 1 1 1 2 2 2 2 9 9 8 9 10 1000000005 876 875 567 566 2000000000 10000001 100...
output:
Case #1: 4611686014132420609 Case #2: 999999999998 Case #3: 214748354700000 Case #4: 21474826470000 Case #5: 8800436568 Case #6: 1000000 Case #7: 0 Case #8: 10 Case #9: 998858410 Case #10: 199003333267 Case #11: 2666666666 Case #12: 2666666664 Case #13: 268435455010000 Case #14: 4294967288 Case #15:...
result:
ok 200 lines