답안 #925685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925685 2024-02-12T07:26:13 Z vjudge1 Kitchen (BOI19_kitchen) C++17
20 / 100
11 ms 4920 KB
#pragma GCC optimize("O3", "unroll-loops") // "Ofast" 	
#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt") 

#include <bits/stdc++.h>

//#define int long long
#define vt vector
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define f first
#define s second
#define dbg(x) cerr << #x << " = " << x << '\n'
#define bit(x, i) ((x) >> (i) & 1)

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 1e6 + 5, mod = 1e9 + 7;
const ll inf = 1e18 + 7;
const ld eps = 1e-6;

ll add (ll a, ll b) {
	a += b;
	if (a < 0) a += mod;
	if (a >= mod) a -= mod;
	return a;
}

ll mul (ll a, ll b) {
	a *= b;
	if (a >= mod) a %= mod;
	return a;
}

int n, m, k, a[N], b[N], dp[N];

void solve () {
	cin >> n >> m >> k;
	int sum = 0;
	for (int i = 1; i <= n; i++) cin >> a[i], sum += a[i];
	for (int i = 1; i <= m; i++) cin >> b[i];
	dp[0] = 1;
	for (int i = 1; i <= m; i++) {
		for (int w = 90000 - b[i]; w >= 0; w--) dp[w + b[i]] |= dp[w];
	}
	for (int i = sum; i <= 90000; i++) {
		if (dp[i]) cout << i - sum << '\n', exit(0);
	}
	cout << "Impossible";
	cout << '\n';
}

bool testcases = 0;

signed main() {
#ifdef AMIR
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
#endif
	cin.tie(0) -> sync_with_stdio(0);
	int test = 1;
	if (testcases) cin >> test;
	for (int cs = 1; cs <= test; cs++) {
		solve();
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4696 KB Output is correct
4 Incorrect 1 ms 4700 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4696 KB Output is correct
4 Incorrect 1 ms 4700 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 4700 KB Output is correct
2 Correct 8 ms 4700 KB Output is correct
3 Correct 10 ms 4920 KB Output is correct
4 Correct 11 ms 4696 KB Output is correct
5 Correct 10 ms 4700 KB Output is correct
6 Correct 7 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4700 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4696 KB Output is correct
2 Correct 1 ms 4700 KB Output is correct
3 Correct 1 ms 4696 KB Output is correct
4 Incorrect 1 ms 4700 KB Output isn't correct
5 Halted 0 ms 0 KB -