답안 #147942

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
147942 2019-08-31T08:53:22 Z MvC Kitchen (BOI19_kitchen) C++11
100 / 100
141 ms 100604 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include<bits/stdc++.h>
//#include "boxes.h"
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=3e2+50;
const int mod=1e9+7;
using namespace std;
int n,m,k,a[nmax],b[nmax],f[nmax][nmax*nmax],sa,sb,i,j;
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m>>k;
	for(i=1;i<=n;i++)cin>>a[i];
	for(i=1;i<=m;i++)
	{
		cin>>b[i];
		sb+=b[i];
	}
	for(i=1;i<=n;i++)
	{
		if(a[i]<k)rc("Impossible");
		sa+=a[i];
	}
	for(i=0;i<=m;i++)
	{
		for(j=0;j<=sb;j++)
		{
			if(j)f[i][j]=-1;
			if(i)f[i][j]=f[i-1][j];
			if(i && j>=b[i] && f[i-1][j-b[i]]!=-1)f[i][j]=max(f[i][j],f[i-1][j-b[i]]+min(b[i],n));
		}
	}
	for(i=sa;i<=sb;i++)if(f[m][i]>=n*k)rc(i-sa);
	rc("Impossible");
	return 0;
}

Compilation message

kitchen.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
kitchen.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 632 KB Output is correct
10 Correct 2 ms 632 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 69112 KB Output is correct
2 Correct 77 ms 51788 KB Output is correct
3 Correct 83 ms 58360 KB Output is correct
4 Correct 139 ms 98844 KB Output is correct
5 Correct 138 ms 99140 KB Output is correct
6 Correct 59 ms 42232 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 760 KB Output is correct
2 Correct 2 ms 632 KB Output is correct
3 Correct 2 ms 760 KB Output is correct
4 Correct 2 ms 760 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 632 KB Output is correct
10 Correct 2 ms 632 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 632 KB Output is correct
14 Correct 94 ms 69112 KB Output is correct
15 Correct 77 ms 51788 KB Output is correct
16 Correct 83 ms 58360 KB Output is correct
17 Correct 139 ms 98844 KB Output is correct
18 Correct 138 ms 99140 KB Output is correct
19 Correct 59 ms 42232 KB Output is correct
20 Correct 2 ms 760 KB Output is correct
21 Correct 2 ms 632 KB Output is correct
22 Correct 2 ms 760 KB Output is correct
23 Correct 2 ms 760 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 69 ms 50668 KB Output is correct
26 Correct 88 ms 62712 KB Output is correct
27 Correct 28 ms 19064 KB Output is correct
28 Correct 73 ms 51576 KB Output is correct
29 Correct 96 ms 70264 KB Output is correct
30 Correct 141 ms 100604 KB Output is correct