Submission #878939

#TimeUsernameProblemLanguageResultExecution timeMemory
878939Tien_NoobKitchen (BOI19_kitchen)C++17
100 / 100
20 ms816 KiB
//Make CSP great again //Vengeance #include <bits/stdc++.h> #define TASK "TESTCODE" using namespace std; const int N = 3e2; int dp[N * N + 1]; int n, m, k, a[N + 1], b[N + 1], sum; void read() { cin >> n >> m >> k; for (int i = 1; i <= n; ++ i) { cin >> a[i]; if (a[i] < k) { cout << "Impossible"; exit(0); } sum += a[i]; } for (int j = 1; j <= m; ++ j) { cin >> b[j]; } } void solve() { memset(dp, -0x3f, sizeof(dp)); dp[0] = 0; for (int j = 1; j <= m; ++ j) { for (int i = N * N - b[j]; i >= 0; -- i) { dp[i + b[j]] = max(dp[i + b[j]], dp[i] + min(n, b[j])); } } for (int i = sum; i <= N * N; ++ i) { if (dp[i] >= n * k) { cout << i - sum; return ; } } cout << "Impossible"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); //freopen(TASK".OUT", "w", stdout); } int t = 1; bool typetest = false; if (typetest) { cin >> t; } for (int __ = 1; __ <= t; ++ __) { //cout << "Case " << __ << ": "; read(); solve(); } }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...