Submission #270314

#TimeUsernameProblemLanguageResultExecution timeMemory
270314BeanZBali Sculptures (APIO15_sculpture)C++17
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 3e6 + 5; ll dp[2005][2005], a[2005], sum[2005]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("VietCT.INP", "r")){ freopen("VietCT.INP", "r", stdin); freopen("VietCT.OUT", "w", stdout); } ll n, L, R; cin >> n >> L >> R; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i]; for (int i = 0; i <= n; i++){ for (int j = 0; j <= R; j++){ dp[j][i] = 1e18; } } for (int i = 1; i <= n; i++) dp[1][i] = sum[i]; for (int i = 2; i <= R; i++){ for (int j = 1; j <= n; j++){ for (int k = 0; k < j; k++){ ll cost = dp[i - 1][k] | (sum[j] - sum[k]); if (dp[i][j] > cost){ dp[i][j] = cost; } } } } ll ans = 1e18; for (int i = L; i <= R; i++){ if (dp[i][n] < ans){ ans = dp[i][n]; } } cout << ans; } /* 6 1 3 8 1 2 1 5 4 */

Compilation message (stderr)

sculpture.cpp: In function 'int main()':
sculpture.cpp:13:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |                 freopen("VietCT.INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
sculpture.cpp:14:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |                 freopen("VietCT.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...
#Verdict Execution timeMemoryGrader output
Fetching results...