Submission #464480

# Submission time Handle Problem Language Result Execution time Memory
464480 2021-08-13T09:37:37 Z fuad27 Kitchen (BOI19_kitchen) C++17
0 / 100
1000 ms 316 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vii vector<pair<int, int>>
#define vi vector<int>
#define vl vector<long long>
#define vll vector<pair<long long, long long>>
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i = a;i<=b;i++)
#define f first
#define s second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define start int tt;cin>>tt;rep(testcase, 1, tt)
#define print(k) cout<<"Case #"<<testcase<<": "<<k<<"\n";
#define endl "\n"
#define DEBUG(k) cerr<<k<<"\n";
#define int long long
long long ans = 1000000000;
long long n, m, k, sum = 0;
long long a[310], b[310];
void f(int ind, vector<long long> t, int s, int ts) {
	if(ind == m) {
		if(s >= n*k and ts >= sum) {
			ans = min(ans, ts);
		}
		return;
	}
	f(ind+1, t, s, ts);
	t.push_back(ind);
	f(ind+1,t, s+min(n, b[ind]), ts + b[ind]);
}
void solve() {
	cin >> n >> m >> k;
	rep(i, 0, n-1) {
		cin>>a[i];
		sum += a[i];
	}
	rep(i, 0, m-1)cin>>b[i];
	vector<int> tmp(0);
	f(0, tmp, 0, 0);
	if(ans == 1000000000)cout<<"Impossible"<<endl;
	else cout<<ans - sum<<endl;
}
int32_t main () {
/*	#ifndef ONLINE_JUDGE
	freopen("stdin", "r", stdin);
	freopen("stdout", "w", stdout);
	freopen("stderr", "w", stderr);
	#endif*/
	int t = 1;
	while(t--) {
		solve();
	}
	return 0;
}
# 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1078 ms 316 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1086 ms 284 KB Time limit exceeded
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 0 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Incorrect 1 ms 204 KB Output isn't correct
8 Halted 0 ms 0 KB -