답안 #576220

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
576220 2022-06-12T14:17:16 Z cheissmart Uplifting Excursion (BOI22_vault) C++14
20 / 100
3220 ms 25916 KB
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

string _reset = "\u001b[0m", _yellow = "\u001b[33m", _bold = "\u001b[1m";
void DBG() { cerr << "]" << _reset << endl; }
template<class H, class...T> void DBG(H h, T ...t) {
	cerr << to_string(h);
	if(sizeof ...(t)) cerr << ", ";
	DBG(t...);
}
#ifdef CHEISSMART
#define debug(...) cerr << _yellow << _bold << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
#define debug(...)
#endif

const int INF = 1e9 + 7, mxM = 102, mxC = mxM * mxM * mxM / 2;

void cmax(ll& a, ll b) {
	a = max(a, b);
}

int m;
ll l, zero;

V<ll> go(ll* a) {
	V<ll> dp(mxC, -1);
	dp[0] = 0;
	for(int i = 1; i <= m; i++) {
		V<ll> ndp(mxC, -1);
		for(int j = 0; j < mxC; j++) if(dp[j] != -1) {
			for(int take = 0; take <= a[i]; take++)
				cmax(ndp[j + take * i], dp[j] + take);
		}
		swap(dp, ndp);
	}
	return dp;
}

ll a[mxM], b[mxM];

signed main()
{
	IO_OP;

	cin >> m >> l;
	for(int i = m; i >= 1; i--)
		cin >> a[i];
	cin >> zero;
	for(int i = 1; i <= m; i++)
		cin >> b[i];

	V<ll> dpa = go(a), dpb = go(b);

	ll mx = -1;
	for(int i = 0; i < mxC; i++) {
		if(i + l < 0 || i + l >= mxC) continue;
		int j = i + l;
		if(dpa[i] != -1 && dpb[j] != -1)
			mx = max(mx, dpa[i] + dpb[j]);
	}
	if(mx == -1) {
		cout << "impossible\n";
		return 0;
	}
	cout << mx + zero << '\n';

}

# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12780 KB Output is correct
2 Correct 12 ms 12780 KB Output is correct
3 Correct 8 ms 12676 KB Output is correct
4 Correct 21 ms 12856 KB Output is correct
5 Correct 122 ms 12704 KB Output is correct
6 Correct 99 ms 12760 KB Output is correct
7 Correct 65 ms 12764 KB Output is correct
8 Correct 92 ms 12768 KB Output is correct
9 Correct 165 ms 12832 KB Output is correct
10 Correct 60 ms 12780 KB Output is correct
11 Correct 64 ms 12724 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12780 KB Output is correct
2 Correct 12 ms 12780 KB Output is correct
3 Correct 8 ms 12676 KB Output is correct
4 Correct 21 ms 12856 KB Output is correct
5 Correct 122 ms 12704 KB Output is correct
6 Correct 99 ms 12760 KB Output is correct
7 Correct 65 ms 12764 KB Output is correct
8 Correct 92 ms 12768 KB Output is correct
9 Correct 165 ms 12832 KB Output is correct
10 Correct 60 ms 12780 KB Output is correct
11 Correct 64 ms 12724 KB Output is correct
12 Correct 11 ms 12716 KB Output is correct
13 Correct 11 ms 12780 KB Output is correct
14 Correct 8 ms 12704 KB Output is correct
15 Correct 21 ms 12692 KB Output is correct
16 Correct 97 ms 12764 KB Output is correct
17 Correct 93 ms 12760 KB Output is correct
18 Correct 86 ms 12872 KB Output is correct
19 Correct 91 ms 12744 KB Output is correct
20 Correct 152 ms 12716 KB Output is correct
21 Correct 59 ms 12744 KB Output is correct
22 Correct 68 ms 12744 KB Output is correct
23 Correct 927 ms 12700 KB Output is correct
24 Correct 976 ms 12768 KB Output is correct
25 Correct 289 ms 12760 KB Output is correct
26 Correct 3220 ms 12756 KB Output is correct
27 Correct 3127 ms 12764 KB Output is correct
28 Correct 153 ms 12756 KB Output is correct
29 Correct 111 ms 12756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 12780 KB Output is correct
2 Runtime error 34 ms 25916 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 12780 KB Output is correct
2 Runtime error 34 ms 25916 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 12780 KB Output is correct
2 Runtime error 34 ms 25916 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12780 KB Output is correct
2 Correct 12 ms 12780 KB Output is correct
3 Correct 8 ms 12676 KB Output is correct
4 Correct 21 ms 12856 KB Output is correct
5 Correct 122 ms 12704 KB Output is correct
6 Correct 99 ms 12760 KB Output is correct
7 Correct 65 ms 12764 KB Output is correct
8 Correct 92 ms 12768 KB Output is correct
9 Correct 165 ms 12832 KB Output is correct
10 Correct 60 ms 12780 KB Output is correct
11 Correct 64 ms 12724 KB Output is correct
12 Correct 19 ms 12780 KB Output is correct
13 Runtime error 34 ms 25916 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 12780 KB Output is correct
2 Runtime error 34 ms 25916 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12780 KB Output is correct
2 Correct 12 ms 12780 KB Output is correct
3 Correct 8 ms 12676 KB Output is correct
4 Correct 21 ms 12856 KB Output is correct
5 Correct 122 ms 12704 KB Output is correct
6 Correct 99 ms 12760 KB Output is correct
7 Correct 65 ms 12764 KB Output is correct
8 Correct 92 ms 12768 KB Output is correct
9 Correct 165 ms 12832 KB Output is correct
10 Correct 60 ms 12780 KB Output is correct
11 Correct 64 ms 12724 KB Output is correct
12 Correct 11 ms 12716 KB Output is correct
13 Correct 11 ms 12780 KB Output is correct
14 Correct 8 ms 12704 KB Output is correct
15 Correct 21 ms 12692 KB Output is correct
16 Correct 97 ms 12764 KB Output is correct
17 Correct 93 ms 12760 KB Output is correct
18 Correct 86 ms 12872 KB Output is correct
19 Correct 91 ms 12744 KB Output is correct
20 Correct 152 ms 12716 KB Output is correct
21 Correct 59 ms 12744 KB Output is correct
22 Correct 68 ms 12744 KB Output is correct
23 Correct 927 ms 12700 KB Output is correct
24 Correct 976 ms 12768 KB Output is correct
25 Correct 289 ms 12760 KB Output is correct
26 Correct 3220 ms 12756 KB Output is correct
27 Correct 3127 ms 12764 KB Output is correct
28 Correct 153 ms 12756 KB Output is correct
29 Correct 111 ms 12756 KB Output is correct
30 Correct 19 ms 12780 KB Output is correct
31 Runtime error 34 ms 25916 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 12780 KB Output is correct
2 Runtime error 34 ms 25916 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 12780 KB Output is correct
2 Correct 12 ms 12780 KB Output is correct
3 Correct 8 ms 12676 KB Output is correct
4 Correct 21 ms 12856 KB Output is correct
5 Correct 122 ms 12704 KB Output is correct
6 Correct 99 ms 12760 KB Output is correct
7 Correct 65 ms 12764 KB Output is correct
8 Correct 92 ms 12768 KB Output is correct
9 Correct 165 ms 12832 KB Output is correct
10 Correct 60 ms 12780 KB Output is correct
11 Correct 64 ms 12724 KB Output is correct
12 Correct 11 ms 12716 KB Output is correct
13 Correct 11 ms 12780 KB Output is correct
14 Correct 8 ms 12704 KB Output is correct
15 Correct 21 ms 12692 KB Output is correct
16 Correct 97 ms 12764 KB Output is correct
17 Correct 93 ms 12760 KB Output is correct
18 Correct 86 ms 12872 KB Output is correct
19 Correct 91 ms 12744 KB Output is correct
20 Correct 152 ms 12716 KB Output is correct
21 Correct 59 ms 12744 KB Output is correct
22 Correct 68 ms 12744 KB Output is correct
23 Correct 927 ms 12700 KB Output is correct
24 Correct 976 ms 12768 KB Output is correct
25 Correct 289 ms 12760 KB Output is correct
26 Correct 3220 ms 12756 KB Output is correct
27 Correct 3127 ms 12764 KB Output is correct
28 Correct 153 ms 12756 KB Output is correct
29 Correct 111 ms 12756 KB Output is correct
30 Correct 19 ms 12780 KB Output is correct
31 Runtime error 34 ms 25916 KB Execution killed with signal 11
32 Halted 0 ms 0 KB -