# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
530431 | 2022-02-25T10:39:56 Z | Killer2501 | Kitchen (BOI19_kitchen) | C++14 | 21 ms | 768 KB |
#include <bits/stdc++.h> #define ll long long #define ld long double #define ull unsigned long long #define pb push_back #define pll pair<ll, ll> #define pii pair<int, int> #define fi first #define se second using namespace std; const int N = 3e2+5; const int M = 1e2+2; const int mod = 1e9+7; const ll base = 75; const int inf = 1e9; int m, n, t, b[N], d[N], lab[N*N]; int k, a[N], dp[N*N]; ll ans, tong; vector<int> adj[N]; vector<pii> vi; string s[N]; bool vis[N]; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n&1)total = total * k % mod; k = k * k % mod; } return total; } void add(int &x, int y) { x += y; if(x >= mod)x -= mod; } int findp(int u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } void hop(int u, int v) { u = findp(u); v = findp(v); if(u == v)return; if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; } void sol() { cin >> n >> m >> k; for(int i = 1; i <= n; i ++) { cin >> a[i]; tong += a[i]; } for(int i = 1; i <= m; i ++)cin >> b[i]; fill_n(dp, N*N, -1); sort(a+1, a+1+n); if(a[1] < k) { cout << "Impossible"; return; } dp[0] = 0; for(int i = 1; i <= m; i ++) { k = min(b[i], n); for(int j = N*N-1; j >= b[i]; j --) if(dp[j-b[i]] != -1)dp[j] = max(dp[j], dp[j-b[i]]+k); } for(int i = tong; i < N*N; i ++) { if(dp[i] >= n*k) { cout << i-tong; return; } } cout << "Impossible"; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "test" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int test = 1; //cin >> test; while(test -- > 0)sol(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 588 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 768 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |