Submission #5928013
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5050, M = N * N;
ll n, a[2], b[2], c[2], dp[M];
void _max(ll &a, ll b) {
a = max(a, b);
}
ll solve(ll n, int now, int nxt) {
memset(dp, 0, sizeof dp);
iota(dp, dp + n + 1, 0);
for (int i = 1; i <= n; i++) {
if(i >= a[now])
_max(dp[i], dp[i - a[now]] + a[nxt]);
if(i >= b[now])
_max(dp[i], dp[i - b[now]] + b[nxt]);
if(i >= c[now])
_max(dp[i], dp[i - c[now]] + c[nxt]);
}
return dp[n];
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cin >> n;
cin >> a[0] >> b[0] >> c[0];
cin >> a[1] >> b[1] >> c[1];
n = solve(n, 0, 1);
n = solve(n, 1, 0);
cout << n;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - Squirrel Merchant |
| User | LODB |
| Language | C++14 (GCC 5.4.1) |
| Score | 600 |
| Code Size | 722 Byte |
| Status | AC |
| Exec Time | 179 ms |
| Memory | 199680 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 600 / 600 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt |
| All | 00.txt, 41.txt, 42.txt, 45.txt, 50.txt, 55.txt, 60.txt, 65.txt, 70.txt, 75.txt, 80.txt, 81.txt, 82.txt, 83.txt, 84.txt, 85.txt, 86.txt, 87.txt, 88.txt, 89.txt, 90.txt, 91.txt, 92.txt, 93.txt, 94.txt, 95.txt, a01.txt, a02.txt, a03.txt, a04.txt, a05.txt, a06.txt, a07.txt, a08.txt, a09.txt, a10.txt, a11.txt, a12.txt, a13.txt, a14.txt, a15.txt, a16.txt, a17.txt, a18.txt, a19.txt, a20.txt, a21.txt, a22.txt, a23.txt, a24.txt, a25.txt, a26.txt, a27.txt, a28.txt, a29.txt, a30.txt, a31.txt, a32.txt, a33.txt, a34.txt, a35.txt, a36.txt, a37.txt, a38.txt, a39.txt, a40.txt, s1.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00.txt | AC | 72 ms | 199552 KiB |
| 41.txt | AC | 73 ms | 199552 KiB |
| 42.txt | AC | 72 ms | 199552 KiB |
| 45.txt | AC | 72 ms | 199552 KiB |
| 50.txt | AC | 72 ms | 199552 KiB |
| 55.txt | AC | 72 ms | 199552 KiB |
| 60.txt | AC | 72 ms | 199552 KiB |
| 65.txt | AC | 72 ms | 199552 KiB |
| 70.txt | AC | 72 ms | 199552 KiB |
| 75.txt | AC | 72 ms | 199552 KiB |
| 80.txt | AC | 72 ms | 199552 KiB |
| 81.txt | AC | 73 ms | 199552 KiB |
| 82.txt | AC | 94 ms | 199552 KiB |
| 83.txt | AC | 92 ms | 199552 KiB |
| 84.txt | AC | 95 ms | 199552 KiB |
| 85.txt | AC | 100 ms | 199552 KiB |
| 86.txt | AC | 158 ms | 199552 KiB |
| 87.txt | AC | 110 ms | 199552 KiB |
| 88.txt | AC | 146 ms | 199552 KiB |
| 89.txt | AC | 84 ms | 199552 KiB |
| 90.txt | AC | 85 ms | 199552 KiB |
| 91.txt | AC | 72 ms | 199552 KiB |
| 92.txt | AC | 73 ms | 199552 KiB |
| 93.txt | AC | 73 ms | 199552 KiB |
| 94.txt | AC | 179 ms | 199552 KiB |
| 95.txt | AC | 155 ms | 199552 KiB |
| a01.txt | AC | 177 ms | 199552 KiB |
| a02.txt | AC | 177 ms | 199552 KiB |
| a03.txt | AC | 177 ms | 199552 KiB |
| a04.txt | AC | 178 ms | 199552 KiB |
| a05.txt | AC | 176 ms | 199552 KiB |
| a06.txt | AC | 177 ms | 199552 KiB |
| a07.txt | AC | 177 ms | 199552 KiB |
| a08.txt | AC | 178 ms | 199552 KiB |
| a09.txt | AC | 176 ms | 199552 KiB |
| a10.txt | AC | 176 ms | 199552 KiB |
| a11.txt | AC | 178 ms | 199552 KiB |
| a12.txt | AC | 176 ms | 199552 KiB |
| a13.txt | AC | 72 ms | 199552 KiB |
| a14.txt | AC | 73 ms | 199552 KiB |
| a15.txt | AC | 73 ms | 199552 KiB |
| a16.txt | AC | 73 ms | 199552 KiB |
| a17.txt | AC | 73 ms | 199552 KiB |
| a18.txt | AC | 73 ms | 199552 KiB |
| a19.txt | AC | 72 ms | 199680 KiB |
| a20.txt | AC | 72 ms | 199552 KiB |
| a21.txt | AC | 73 ms | 199552 KiB |
| a22.txt | AC | 72 ms | 199552 KiB |
| a23.txt | AC | 73 ms | 199552 KiB |
| a24.txt | AC | 73 ms | 199552 KiB |
| a25.txt | AC | 72 ms | 199552 KiB |
| a26.txt | AC | 72 ms | 199552 KiB |
| a27.txt | AC | 72 ms | 199552 KiB |
| a28.txt | AC | 73 ms | 199552 KiB |
| a29.txt | AC | 73 ms | 199552 KiB |
| a30.txt | AC | 73 ms | 199552 KiB |
| a31.txt | AC | 72 ms | 199552 KiB |
| a32.txt | AC | 72 ms | 199552 KiB |
| a33.txt | AC | 73 ms | 199552 KiB |
| a34.txt | AC | 73 ms | 199552 KiB |
| a35.txt | AC | 72 ms | 199552 KiB |
| a36.txt | AC | 72 ms | 199552 KiB |
| a37.txt | AC | 72 ms | 199552 KiB |
| a38.txt | AC | 72 ms | 199552 KiB |
| a39.txt | AC | 73 ms | 199552 KiB |
| a40.txt | AC | 73 ms | 199552 KiB |
| s1.txt | AC | 72 ms | 199552 KiB |