Submission #928810

# Submission time Handle Problem Language Result Execution time Memory
928810 2024-02-17T06:06:25 Z Sir_Ahmed_Imran Kitchen (BOI19_kitchen) C++17
100 / 100
21 ms 816 KB
                              ///~~~LOTA~~~///
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define append push_back
#define add insert
#define nl "\n"
#define ff first
#define ss second
#define pii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define L0TA ios_base::sync_with_stdio(false);cin.tie(NULL)
#define N 90001
int dp[N];
void solve(){
    int n,m,o,p,q,r;
    cin>>n>>m>>o;
    for(int i=0;i<N;i++)
        dp[i]=-1e8;
    for(int i=dp[0]=r=0;i<n;i++){
        cin>>p;
        r+=p;
        if(p<o){
            cout<<"Impossible";
            return;
        }
    }
    for(int i=0;i<m;i++){
        cin>>p;
        q=min(p,n);
        for(int j=N-p-1;j>=0;j--)
            dp[j+p]=max(dp[j+p],dp[j]+q);
    }
    for(int i=0;r+i<N;i++){
        if(dp[i+r]>=o*n){
            cout<<i;
            return;
        }
    }
    cout<<"Impossible";
}
int main(){
    L0TA;
    solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 604 KB Output is correct
2 Correct 15 ms 604 KB Output is correct
3 Correct 21 ms 604 KB Output is correct
4 Correct 20 ms 600 KB Output is correct
5 Correct 21 ms 600 KB Output is correct
6 Correct 14 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 604 KB Output is correct
2 Correct 3 ms 604 KB Output is correct
3 Correct 3 ms 604 KB Output is correct
4 Correct 3 ms 600 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Correct 0 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 2 ms 600 KB Output is correct
10 Correct 2 ms 604 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 604 KB Output is correct
14 Correct 18 ms 604 KB Output is correct
15 Correct 15 ms 604 KB Output is correct
16 Correct 21 ms 604 KB Output is correct
17 Correct 20 ms 600 KB Output is correct
18 Correct 21 ms 600 KB Output is correct
19 Correct 14 ms 604 KB Output is correct
20 Correct 3 ms 604 KB Output is correct
21 Correct 3 ms 604 KB Output is correct
22 Correct 3 ms 604 KB Output is correct
23 Correct 3 ms 600 KB Output is correct
24 Correct 1 ms 604 KB Output is correct
25 Correct 14 ms 600 KB Output is correct
26 Correct 17 ms 604 KB Output is correct
27 Correct 11 ms 604 KB Output is correct
28 Correct 21 ms 604 KB Output is correct
29 Correct 17 ms 816 KB Output is correct
30 Correct 20 ms 600 KB Output is correct