# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433521 | kiennguyen246 | Discharging (NOI20_discharging) | C++14 | 151 ms | 13872 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/**
* \author Nguyen Duc Kien
* \date 20/06/2021
*/
///Task name
#define TASK ""
///-------------------------------------------///
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
int n, a[maxn];
namespace Sub2
{
long long f[2005];
int mx[2005][2005];
void Main()
{
for (int i = 1; i <= n; i ++)
for (int j = 1; j <= n; j ++)
mx[i][j] = (i != j ? - 1e9 - 69 : a[i]);
for (int i = 1; i <= n; i ++)
for (int j = i + 1; j <= n; j ++)
mx[i][j] = max(mx[i][j - 1], a[j]);
f[0] = 0;
for (int i = 1; i <= n; i ++) f[i] = 1e18 + 69;
for (int i = 1; i <= n; i ++)
{
for (int j = 0; j < i; j ++)
{
f[i] = min({f[i], f[j] + 1ll * mx[j + 1][i] * (n - j)});
}
}
cout << f[n];
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cerr << "Processing...\n\n";
if (fopen(TASK".INP", "r"))
{
freopen(TASK".INP", "r", stdin);
// freopen(TASK".OUT", "w", stdout);
}
cin >> n;
for (int i = 1; i <= n; i ++) cin >> a[i];
if (n <= 1500) Sub2::Main();
cerr << "\n\n-----------------\n";
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |