Submission #525509

# Submission time Handle Problem Language Result Execution time Memory
525509 2022-02-11T19:58:15 Z Yazan_Alattar Kitchen (BOI19_kitchen) C++14
9 / 100
97 ms 300 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 507;
const ll inf = 2e9;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int n, m, k, a[M], b[M], sum, cnt[M], ans = inf;
 
int main()
{
	scanf("%d%d%d", &n, &m, &k);
	for(int i = 1; i <= n; ++i){
		scanf("%d", &a[i]);
		sum += a[i];
		if(a[i] < k) printf("Impossible\n"), exit(0);
	}
	for(int i = 0; i < m; ++i) scanf("%d", &b[i]);
	
	for(int mask = 0; mask < (1 << m); ++mask){
		for(int i = 1; i <= n; ++i) cnt[i] = 0;
		int tot = 0;
		
		for(int j = 0; j < m; ++j) if((mask >> j) & 1){
			tot += b[j];
			int rem = b[j];
			for(int i = 1; i <= n; ++i) if(rem && cnt[i] < k) ++cnt[i], --rem;
		}
		
		bool ok = (tot >= sum);
		for(int i = 1; i <= n; ++i) ok &= (cnt[i] == k);
		
		if(ok) ans = min(ans, tot - sum);
	}
	
	if(ans == inf) printf("Impossible\n");
	else printf("%d\n", ans);
	return 0;
}

Compilation message

kitchen.cpp: In function 'int main()':
kitchen.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d%d%d", &n, &m, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
kitchen.cpp:21:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
kitchen.cpp:25:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |  for(int i = 0; i < m; ++i) scanf("%d", &b[i]);
      |                             ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 5 ms 204 KB Output is correct
10 Correct 4 ms 296 KB Output is correct
11 Correct 6 ms 204 KB Output is correct
12 Correct 10 ms 204 KB Output is correct
13 Incorrect 97 ms 280 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 296 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 296 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 5 ms 204 KB Output is correct
10 Correct 4 ms 296 KB Output is correct
11 Correct 6 ms 204 KB Output is correct
12 Correct 10 ms 204 KB Output is correct
13 Incorrect 97 ms 280 KB Output isn't correct
14 Halted 0 ms 0 KB -