# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745976 | 2023-05-21T10:17:50 Z | vjudge1 | Kitchen (BOI19_kitchen) | C++17 | 1000 ms | 300 KB |
#include <bits/stdc++.h> using namespace std; using ll = long long int; const ll mod = 1e9 + 7; ll f(vector<ll>& t, vector<ll>& v, int k){ vector<pair<ll, int>> p; for(auto i : v){ p.push_back({i, 0}); } for(auto& i : t){ for(int j = 0; j < p.size(); ++j){ if(i > 0 && p[j].second < k){ //mindehol legalabb k chef --i; --p[j].first; ++p[j].second; } } } ll sumv = 0, sumt = 0; for(int j = 0; j < p.size(); ++j){ if(p[j].second < k){ return 1e9; } sumv += p[j].first; } for(auto& i : t){ sumt += i; } if(sumt - sumv < 0) return 1e9; return sumt - sumv; } int main(){ int n, m, k; cin >> n >> m >> k; vector<ll> v(n), t(m); ll sumv = 0; for(auto& i : v){ cin >> i; } for(auto& i : t){ cin >> i; } /*if(m < k || *min_element(begin(v), end(v)) < k){ cout << "Impossible" << endl; return 0; }*/ ll sol = 1e9; for(ll i = 0; i < (1ll << m); ++i){ vector<ll> munkas; for(int j = 0; j < m; ++j){ if((1ll << j) & i){ munkas.push_back(t[j]); } } sol = min(sol, f(munkas, v, k)); } if(sol == 1e9){ cout << "Impossible" << endl; } else{ cout << sol << endl; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Incorrect | 0 ms | 212 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Incorrect | 0 ms | 212 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1061 ms | 288 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 300 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Incorrect | 0 ms | 212 KB | Output isn't correct |
8 | Halted | 0 ms | 0 KB | - |