답안 #243085

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
243085 2020-06-30T09:32:46 Z dynam1c Kitchen (BOI19_kitchen) C++17
100 / 100
92 ms 896 KB
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n, m, k;
	cin >> n >> m >> k;
	vi meals(n);
	vi chefs(m);
	rep(i, n) cin >> meals[i];
	rep(i, m) cin >> chefs[i];

	rep(i, n) if (meals[i] < k) {
		cout << "Impossible\n";
		return 0;
	}

	vi arr(301*301, -1);
	arr[0] = 0;
	rep(i, m) rrep(j, arr.size()) if (arr[j] != -1) arr[j+chefs[i]] = max(arr[j+chefs[i]], arr[j] + min(chefs[i], n));

	int s = 0;
	rep(i, n) s += meals[i];
	loop(i, s, arr.size()) if (arr[i] >= n*k) {
		cout << i-s << endl;
		return 0;
	}
	cout << "Impossible\n";
}

Compilation message

kitchen.cpp:1:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/stack:200000000")
 
kitchen.cpp: In function 'int main()':
kitchen.cpp:10:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define loop(i, a, b) for(int i = a; i < (b); i++)
                                        ^
kitchen.cpp:73:2: note: in expansion of macro 'loop'
  loop(i, s, arr.size()) if (arr[i] >= n*k) {
  ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 6 ms 640 KB Output is correct
10 Correct 6 ms 768 KB Output is correct
11 Correct 6 ms 640 KB Output is correct
12 Correct 6 ms 640 KB Output is correct
13 Correct 7 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 816 KB Output is correct
2 Correct 33 ms 640 KB Output is correct
3 Correct 65 ms 896 KB Output is correct
4 Correct 89 ms 768 KB Output is correct
5 Correct 76 ms 640 KB Output is correct
6 Correct 34 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 640 KB Output is correct
2 Correct 8 ms 640 KB Output is correct
3 Correct 8 ms 640 KB Output is correct
4 Correct 8 ms 640 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 768 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 640 KB Output is correct
4 Correct 5 ms 768 KB Output is correct
5 Correct 5 ms 512 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 5 ms 256 KB Output is correct
8 Correct 5 ms 640 KB Output is correct
9 Correct 6 ms 640 KB Output is correct
10 Correct 6 ms 768 KB Output is correct
11 Correct 6 ms 640 KB Output is correct
12 Correct 6 ms 640 KB Output is correct
13 Correct 7 ms 768 KB Output is correct
14 Correct 40 ms 816 KB Output is correct
15 Correct 33 ms 640 KB Output is correct
16 Correct 65 ms 896 KB Output is correct
17 Correct 89 ms 768 KB Output is correct
18 Correct 76 ms 640 KB Output is correct
19 Correct 34 ms 640 KB Output is correct
20 Correct 8 ms 640 KB Output is correct
21 Correct 8 ms 640 KB Output is correct
22 Correct 8 ms 640 KB Output is correct
23 Correct 8 ms 640 KB Output is correct
24 Correct 5 ms 384 KB Output is correct
25 Correct 24 ms 640 KB Output is correct
26 Correct 33 ms 640 KB Output is correct
27 Correct 28 ms 640 KB Output is correct
28 Correct 57 ms 640 KB Output is correct
29 Correct 66 ms 768 KB Output is correct
30 Correct 92 ms 768 KB Output is correct