Submission #1135035

#TimeUsernameProblemLanguageResultExecution timeMemory
1135035lucaskojimaKitchen (BOI19_kitchen)C++17
9 / 100
0 ms328 KiB
// subtask 1 #include "bits/stdc++.h" #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x).size() using namespace std; using ll = long long; using pii = pair<int, int>; const char nl = '\n'; const ll LINF = 0x3f3f3f3f3f3f3f3f; const int INF = 0x3f3f3f3f; int main() { ios::sync_with_stdio(0), cin.tie(0); int n, m, k; cin >> n >> m >> k; // 1 <= m <= 2 vector<int> a(n); for (auto &x : a) cin >> x; vector<int> b(m); for (auto &x : b) cin >> x; int sumA = accumulate(all(a), 0); int sumB = accumulate(all(b), 0); if (sumB < sumA || m < k || *min_element(all(a)) < k) { cout << "Impossible" << nl; return 0; } if (m == 1) { if (k == 1 && b[0] >= sumA) cout << b[0] - sumA << nl; else cout << "Impossible" << nl; } if (m == 2) { if (k == 1) { int ans = INF; if (b[0] >= sumA) ans = min(ans, b[0] - sumA); if (b[1] >= sumA) ans = min(ans, b[1] - sumA); if (b[0] + b[1] >= sumA) ans = min(ans, b[0] + b[1] - sumA); if (ans == INF) cout << "Impossible" << nl; else cout << ans << nl; } else if (k == 2) { if (b[0] + b[1] >= sumA && b[0] >= n && b[1] >= n) cout << b[0] + b[1] - sumA << nl; else cout << "Impossible" << nl; } else { cout << "Impossible" << nl; } } return 0; }
#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...