답안 #134928

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134928 2019-07-23T12:21:42 Z miguel Kitchen (BOI19_kitchen) C++14
100 / 100
85 ms 1272 KB
#include<bits/stdc++.h>
using namespace std;
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define sz size()
#define x first
#define y second
#define pi pair <int, int>
#define pii pair <int, pi>
#define vi vector <int>
#define nmax 301
const ll mod = 998244353;
int n, m, k, s;
int a[605], b[605], dp[2][1000001];

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    //cout<<100000;
    cin>>n>>m>>k;
    //if(m<k) return cout<<"Impossible", 0;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        s+=a[i];
        if(a[i]<k) return cout<<"Impossible", 0;
    }
    for(int i=1; i<=m; i++) cin>>b[i];
    for(int i=0; i<=100000; i++){
        dp[0][i]=dp[1][i]=-(1<<30);
    }
    dp[0][0]=0;
    //int cur=0;
    for(int i=1; i<=m; i++){
        for(int h=0; h<=100000; h++){
            if(dp[0][h]==-(1<<30)) continue;
            dp[1][h]=max(dp[0][h], dp[1][h]);
            dp[1][h+b[i]]=max(dp[0][h+b[i]], dp[0][h]+min(b[i], n));
        }
        //cur+=b[i];
        for(int h=0; h<=100000; h++) dp[0][h]=dp[1][h];
    }
    //cout<<"xd";
    for(int h=s; h<=100000; h++){
        //cout<<h<<" "<<dp[0][h]<<endl;
        if(dp[0][h]>=n*k) return cout<<h-s, 0;
    }
    cout<<"Impossible";

}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 1 ms 1144 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 1 ms 1144 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 5 ms 1144 KB Output is correct
10 Correct 5 ms 1148 KB Output is correct
11 Correct 5 ms 1064 KB Output is correct
12 Correct 5 ms 1144 KB Output is correct
13 Correct 5 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 1192 KB Output is correct
2 Correct 44 ms 1184 KB Output is correct
3 Correct 72 ms 1224 KB Output is correct
4 Correct 85 ms 1188 KB Output is correct
5 Correct 77 ms 1220 KB Output is correct
6 Correct 40 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 1144 KB Output is correct
2 Correct 8 ms 1144 KB Output is correct
3 Correct 8 ms 1144 KB Output is correct
4 Correct 9 ms 1144 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 1148 KB Output is correct
2 Correct 3 ms 1144 KB Output is correct
3 Correct 3 ms 1144 KB Output is correct
4 Correct 3 ms 1144 KB Output is correct
5 Correct 1 ms 1144 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 1144 KB Output is correct
9 Correct 5 ms 1144 KB Output is correct
10 Correct 5 ms 1148 KB Output is correct
11 Correct 5 ms 1064 KB Output is correct
12 Correct 5 ms 1144 KB Output is correct
13 Correct 5 ms 1144 KB Output is correct
14 Correct 52 ms 1192 KB Output is correct
15 Correct 44 ms 1184 KB Output is correct
16 Correct 72 ms 1224 KB Output is correct
17 Correct 85 ms 1188 KB Output is correct
18 Correct 77 ms 1220 KB Output is correct
19 Correct 40 ms 1144 KB Output is correct
20 Correct 9 ms 1144 KB Output is correct
21 Correct 8 ms 1144 KB Output is correct
22 Correct 8 ms 1144 KB Output is correct
23 Correct 9 ms 1144 KB Output is correct
24 Correct 2 ms 376 KB Output is correct
25 Correct 36 ms 1144 KB Output is correct
26 Correct 46 ms 1184 KB Output is correct
27 Correct 33 ms 1272 KB Output is correct
28 Correct 59 ms 1144 KB Output is correct
29 Correct 66 ms 1144 KB Output is correct
30 Correct 85 ms 1144 KB Output is correct