Submission #1322066

#TimeUsernameProblemLanguageResultExecution timeMemory
1322066dangcoderHolding (COCI20_holding)C++20
110 / 110
25 ms2360 KiB
/* '########:::::'###::::'##::: ##::'######::::'######:::'#######::'########::'########:'########:: ##.... ##:::'## ##::: ###:: ##:'##... ##::'##... ##:'##.... ##: ##.... ##: ##.....:: ##.... ##: ##:::: ##::'##:. ##:: ####: ##: ##:::..::: ##:::..:: ##:::: ##: ##:::: ##: ##::::::: ##:::: ##: ##:::: ##:'##:::. ##: ## ## ##: ##::'####: ##::::::: ##:::: ##: ##:::: ##: ######::: ########:: ##:::: ##: #########: ##. ####: ##::: ##:: ##::::::: ##:::: ##: ##:::: ##: ##...:::: ##.. ##::: ##:::: ##: ##.... ##: ##:. ###: ##::: ##:: ##::: ##: ##:::: ##: ##:::: ##: ##::::::: ##::. ##:: ########:: ##:::: ##: ##::. ##:. ######:::. ######::. #######:: ########:: ########: ##:::. ##: ........:::..:::::..::..::::..:::......:::::......::::.......:::........:::........::..:::::..:: */ #include<bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if(fopen(".INP", "r")) { freopen(".INP", "r", stdin); freopen(".OUT", "w", stdout); } int n, l, r, k; cin >> n >> l >> r >> k; vector<int> a(n + 1); for(int i = 1; i <= n; i++) cin >> a[i]; int len = r - l + 1; vector<vector<int>> dp(len + 1, vector<int>(k + 1, 1e9)); dp[0][0] = 0; for(int i = 1; i <= n; i++) { for(int j = min(len, i); j >= 1; --j) { int d = abs(i - (l + j - 1)); for(int s = k; s >= d; s--) dp[j][s] = min(dp[j][s], dp[j - 1][s - d] + a[i]); } } int ans = 1e9; for(int s = 0; s <= k; s++) ans = min(ans, dp[len][s]); cout << ans; return 0; }

Compilation message (stderr)

holding.cpp: In function 'int main()':
holding.cpp:21:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |                 freopen(".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~
holding.cpp:22:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 freopen(".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...