Submission #1282559

#TimeUsernameProblemLanguageResultExecution timeMemory
1282559abyfuK blocks (IZhO14_blocks)C++20
53 / 100
1096 ms4428 KiB
//OwO //#pragma GCC optimize("O3", "unroll-loops") #include <bits/stdc++.h> #define ll long long #define ld long double #define namein "input.txt" #define nameout "output.txt" #define pque priority_queue #define all(x) x.begin(),x.end() #define fi first #define se second #define pb push_back #define m_pi acos(-1) using namespace std; const ll inf = 1e18; const int linf = 1.5e9; void file(){ if (fopen(namein, "r")){ freopen(namein, "r", stdin); freopen(nameout, "w", stdout); } } const ll mod = 1e9 + 7; const int N = 1e5 + 5, M = 1e2 + 5; int dp[N][M]; int a[N]; void run(){ int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i]; int mx = 0; for (int i = 1; i <= n; i++){ mx = max(mx, a[i]); dp[i][1] = mx; for (int j = 2; j <= k; j++) dp[i][j] = linf; } for (int i = 2; i <= n; i++){ for (int j = 2; j <= min(i, k); j++){ //dp[i][j] = linf; int mx = 0; for (int k = i; k > 1; k--){ mx = max(mx, a[k]); dp[i][j] = min(dp[i][j], dp[k - 1][j - 1] + mx); } } } //int r = linf; cout << dp[n][k]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); file(); run(); }

Compilation message (stderr)

blocks.cpp: In function 'void file()':
blocks.cpp:20:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |         freopen(namein, "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
blocks.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |         freopen(nameout, "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...