# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1105759 |
2024-10-27T16:57:03 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
1000 ms |
592 KB |
#include <bits/stdc++.h>
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int n, m, k;
std::cin >> n >> m >> k;
std::vector<int> a(n), b(m);
for (int i = 0; i < n; i++) {
std::cin >> a[i];
}
for (int i = 0; i < m; i++) {
std::cin >> b[i];
}
int64_t sum = 0;
for (int i = 0; i < m; i++) {
sum += b[i];
}
if (k == 1) {
std::sort(a.begin(), a.end());
std::reverse(a.begin(), a.end());
std::set<std::pair<int, int>> s;
for (int i = 0; i < m; i++) {
s.insert({b[i], i});
}
int64_t ans = 0;
for (int i = 0; i < n; i++) {
while (a[i] > 0) {
auto it = s.lower_bound({a[i], -1});
if (it == s.end()) {
if (s.empty()) {
std::cout << "Impossible\n";
continue;
}
auto it = s.rbegin();
a[i] -= it->first;
continue;
}
ans += a[i];
s.erase(it);
s.insert({it->first - a[i], it->second});
}
}
std::cout << sum - ans << "\n";
return 0;
}
assert(false);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1044 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
592 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1068 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |