Submission #1004382

#TimeUsernameProblemLanguageResultExecution timeMemory
1004382coolboy19521Kitchen (BOI19_kitchen)C++17
0 / 100
63 ms348 KiB
#pragma GCC optimize("Ofast") #include"bits/stdc++.h" #define int long long using namespace std; const int sz = 3e2 + 6; int a[sz], b[sz]; signed main() { cin.tie(nullptr)->sync_with_stdio(false); int n, m, k; cin >> n >> m >> k; int sm = 0; for (int i = 1; i <= n; i ++) { cin >> a[i]; sm += a[i]; } for (int i = 1; i <= m; i ++) { cin >> b[i]; } if (k > m) { cout << "Impossible"; return 0; } if (1 == m) { int r = (sm / b[1]) * b[1]; if (r < sm) r += b[1]; cout << r - sm; } else if (2 == m) { int r = INT_MAX; int d = 2 == k; for (int i = d; i <= 10000; i ++) { for (int j = d; j <= 10000; j ++) { if (i * b[1] + j * b[2] >= sm) { r = min(r, i * b[1] + j * b[2] - sm); } } } cout << r; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...