# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1088332 | vjudge1 | Discharging (NOI20_discharging) | C++17 | 65 ms | 17744 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.
#include<bits/stdc++.h>
#define taskname ""
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
#define Faster ios_base::sync_with_stdio(false);cin.tie(0);
const int maxn=1e6+33;
const int N=1e5;
const int mod=1e9+7;
const long long INF=1e18+2;
int n,cost[1505][1505],a[maxn];
int dp[maxn];
void sub1()
{
for(int i=1;i<=n;i++)
{
cost[i][i]=a[i];
for(int j=i+1;j<=n;j++)
{
cost[i][j]=max(cost[i][j-1],a[j]);
}
}
for(int i=1;i<=n;i++)
{
dp[i]=cost[1][i]*n;
for(int j=1;j<i;j++)
{
dp[i]=min(dp[i],dp[j]+cost[j+1][i]*(n-j));
}
}
cout<<dp[n];
}
void sub2()
{
}
signed main()
{
if (fopen(taskname".INP","r"))
{
freopen(taskname".INP","r",stdin);
freopen(taskname".OUT","w",stdout);
}
Faster
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>a[i];
}
if(n<=1500) sub1();
else sub2();
}
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... |