# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1014612 | 2024-07-05T08:02:17 Z | Error404 | Kitchen (BOI19_kitchen) | C++17 | 81 ms | 137904 KB |
#include "bits/stdc++.h" using namespace std; #define ll long long #define f first #define s second #define pi pair<ll,ll> #define vi vector<ll> #define vd vector<double> #define vpi vector<pi> #define pb push_back #define INF 1e18 #define endl '\n' //#define int ll #define pii pair<pi,ll> const int mod = 1e9+7; const int MAX = 1e5+1; const int LOG = 30; vi g[MAX]; int tin[MAX], val[MAX], tout[MAX]; int up[LOG+1][MAX]; map<pi,int>mp; vector<pi>order; int timer = 0; signed main(){ int n,m,k,a,b; cin >>n >> m >> k; int dish[n+1], chef[m+1]; ll sum = 0, target = 0;; bool flag = false; for(int i= 1; i<= n; i++){ cin >> dish[i]; target += dish[i]; if(dish[i]<k) { flag = true; } } for(int i = 1; i <=m; i++){ cin >> chef[i]; sum +=chef[i]; } if(flag){ cout << "Impossible" << endl; return 0; } ll dp[m+1][sum+1]; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i =1; i <= m; i++){ for(int j = 0; j<=sum; j++){ dp[i][j] = dp[i-1][j]; if(j>=chef[i] && dp[i][j-chef[i]]) dp[i][j] = max(dp[i][j], dp[i-1][j-chef[i]]+ min(chef[i], n)); } } for(int i = target; i <= sum; i++){ // cout <<dp[m][i]<<" "<< i << endl; if(dp[m][i]-1>=n*k){ cout << i-target << endl; return 0; } } cout << "Impossible" << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2648 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2648 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Incorrect | 2 ms | 3164 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 81 ms | 137904 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 3164 KB | Output is correct |
2 | Correct | 1 ms | 3036 KB | Output is correct |
3 | Correct | 1 ms | 3164 KB | Output is correct |
4 | Correct | 2 ms | 3164 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2648 KB | Output is correct |
2 | Correct | 1 ms | 2652 KB | Output is correct |
3 | Correct | 1 ms | 2652 KB | Output is correct |
4 | Correct | 1 ms | 2652 KB | Output is correct |
5 | Correct | 1 ms | 2652 KB | Output is correct |
6 | Correct | 1 ms | 2652 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2648 KB | Output is correct |
9 | Correct | 1 ms | 3164 KB | Output is correct |
10 | Correct | 1 ms | 2908 KB | Output is correct |
11 | Correct | 1 ms | 2652 KB | Output is correct |
12 | Correct | 1 ms | 2652 KB | Output is correct |
13 | Incorrect | 2 ms | 3164 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |