답안 #771574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
771574 2023-07-03T06:36:47 Z NeroZein Kitchen (BOI19_kitchen) C++17
9 / 100
64 ms 320 KB
#include "bits/stdc++.h"
#define int long long
using namespace std;
 
#ifdef Nero
#include "Deb.h"
#else
#define deb(...)
#endif
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n); 
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<int> b(m); 
  for (int i = 0; i < m; ++i) {
    cin >> b[i]; 
  }
  int tot = accumulate(a.begin(), a.end(), 0ll); 
  int ans = INT_MAX;
  for (int mask = 1; mask < (1 << m); ++mask) {
    int s = 0;
    vector<int> cnt(n); 
    for (int i = 0; i < m; ++i) {
      if (mask >> i & 1) {
        s += b[i];
        for (int j = 0, c = 0; j < n && c < b[i]; ++j) {
          if (cnt[j] < k && cnt[j] < a[j]) {
            c++;
            cnt[j]++; 
          }
        }
      }
    }
    if (s < tot) {
      continue; 
    }
    if (*min_element(cnt.begin(), cnt.end()) >= k) {
      ans = min(ans, s - tot); 
    }
  }
  if (ans == INT_MAX) {
    cout << "Impossible" << '\n';
  } else {
    cout << ans << '\n'; 
  }
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 292 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 292 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 6 ms 320 KB Output is correct
12 Correct 8 ms 212 KB Output is correct
13 Incorrect 64 ms 300 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 4 ms 292 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 4 ms 212 KB Output is correct
10 Correct 4 ms 212 KB Output is correct
11 Correct 6 ms 320 KB Output is correct
12 Correct 8 ms 212 KB Output is correct
13 Incorrect 64 ms 300 KB Output isn't correct
14 Halted 0 ms 0 KB -