# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
745979 | 2023-05-21T10:19:09 Z | vjudge1 | Kitchen (BOI19_kitchen) | C++17 | 1000 ms | 332 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 && p[j].first > 0){ //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 | 1 ms | 280 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
# | 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 | 1 ms | 280 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 16 ms | 212 KB | Output is correct |
10 | Correct | 12 ms | 212 KB | Output is correct |
11 | Correct | 24 ms | 296 KB | Output is correct |
12 | Correct | 40 ms | 332 KB | Output is correct |
13 | Incorrect | 307 ms | 304 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 304 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1054 ms | 280 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 | 1 ms | 280 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 16 ms | 212 KB | Output is correct |
10 | Correct | 12 ms | 212 KB | Output is correct |
11 | Correct | 24 ms | 296 KB | Output is correct |
12 | Correct | 40 ms | 332 KB | Output is correct |
13 | Incorrect | 307 ms | 304 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |