답안 #423254

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
423254 2021-06-10T20:48:54 Z abdzag Kitchen (BOI19_kitchen) C++17
20 / 100
22 ms 4132 KB
#include<bits/stdc++.h>
#include<unordered_map>
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define rrep(i,a,b) for(int i=int(a);i>int(b);i--)
#define trav(a,v) for(auto& a: v)
#define sz(v) v.size()
#define all(v) v.begin(),v.end()
#define vi vector<int>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const long long inf = 1e15;

using namespace std;
int main() {
	cin.sync_with_stdio(false);
	ll n, m, k;
	cin >> n >> m >> k;
	vector<ll> v(n);
	vector<ll> v2(m);
	rep(i, 0, n)cin >> v[i];
	rep(i, 0, m)cin >> v2[i];
	ll sum = 0;
	rep(i, 0, n)sum += v[i];
	set<ll> s;
	bitset<100000> dp;
	bitset<100000> dp2;
	dp[0] = 1;
	rep(i, 0, m) {
		dp2 = dp2 | dp << v2[i];
		dp = dp2;
	}
	rep(i, 0, 1e5)if (dp[i])s.insert(i);
	if (s.lower_bound(sum) == s.end())cout << "Impossible" << endl;
	else cout << *(s.lower_bound(sum)) - sum << endl;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1712 KB Output is correct
2 Correct 8 ms 1820 KB Output is correct
3 Correct 14 ms 2592 KB Output is correct
4 Correct 20 ms 4132 KB Output is correct
5 Correct 22 ms 3956 KB Output is correct
6 Correct 6 ms 1356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Incorrect 1 ms 332 KB Output isn't correct
3 Halted 0 ms 0 KB -