제출 #365755

#제출 시각아이디문제언어결과실행 시간메모리
365755YomapeedKitchen (BOI19_kitchen)C++17
0 / 100
131 ms216004 KiB
#include<bits/stdc++.h> #define pi 3.141592653589793238 #pragma GCC target ("avx2") #pragma GCC optimization ("O3") #pragma GCC optimization ("unroll-loops") #define MOD 1000000007 #define INF 999999999999999999 #define pb push_back #define ff first #define ss second #define mt make_tuple #define ll long long #define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); using namespace std; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// const int N = 3e2 + 2; ll dp[N][N][N]; void chmin(ll& a, ll b){ a = min(a, b); } int main() { //freopen("input.txt", "r", stdin); //freopen("output.txt", "w", stdout); fast; ll T = 1, i, j; //cin >> T; while (T--) { ll n, m, k; cin >> n >> m >> k; vector<ll> a(n), b(m); bool flag = true; ll sum = 0; ll sa = 0; for(i = 0; i < n; i++){ cin >> a[i]; if(a[i] < k){ flag = false; } sum += a[i]; } sa = sum; for(i = 0; i < m; i++){ cin >> b[i]; sum -= b[i]; } if(sum > 0){ flag = false; } if(m < k){ flag = false; } if(!flag){ cout << "Impossible\n"; return 0; } for(i = 0; i < N; i++){ for(j = 0; j < N; j++){ for(ll jj = 0; jj < N; jj++){ dp[i][j][jj] = INF; } } } dp[0][0][0] = 0; for(i = 0; i < m; i++){ ll B = min(b[i], n); for(ll x = 0; x < n; x++){ for(ll done = 0; done <= k; done++){ if(dp[i][x][done] == INF){ continue; } if(x + B < n){ chmin(dp[i + 1][x + B][done], dp[i][x][done] + b[i]); //cout << dp[i + 1][x + B][done] << " " << i + 1 << " " << x + B << " " << done << endl; } else{ chmin(dp[i + 1][x + B - n][done + 1], dp[i][x][done] + b[i]); //cout << dp[i + 1][x + B - n][done + 1] << " " << i + 1 << " " << x + B - n << " " << done + 1 << endl; } } } } // if(dp[m][0][k] == INF){ // cout << "Impossible\n"; // return 0; // } ll ans = dp[m][0][k] - sa; for(i = 0; i < n; i++){ chmin(ans, dp[m][i][k] - sa); } if(ans >= 1000000){ cout << "Impossible\n"; return 0; } cout << ans << endl; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

kitchen.cpp:4: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
kitchen.cpp:5: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...