# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1084442 | _rain_ | Discharging (NOI20_discharging) | C++14 | 8 ms | 3164 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>
using namespace std;
#define ll long long
#define fixbug true
const ll INF = (ll)4e18+7;
const int maxn = 1e5;
ll a[maxn+2] ;
int n;
namespace subtask1{
bool check(){
return n <= 1500;
}
const int N = 1500;
ll f[N+2] , sum[N+2] = {};
void main_code(){
for (int i = 1; i <= n; ++i) f[i] = INF , sum[i] = INF;
for (int i = 1; i <= n; ++i){
ll mx = a[i];
for (int j = i; j >= 1; --j){
mx = max(mx , a[j]);
//ll v = f[j - 1] + sum[j - 1] * i - sum[j - 1] * (j + 1) + mx * i - mx * (j + 1);
f[i] = min(f[i] , f[j - 1] + mx * (n - j + 1));
}
}
cout << f[n];
return;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
#define name "main"
if (fopen(name".inp","r")){
freopen(name".inp","r",stdin);
}
cin >> n;
for (int i = 1; i <= n; ++i) cin >> a[i];
if (subtask1::check()) {
subtask1::main_code();
exit(0);
}
//subtask2::main_code();
exit(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... |