이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
using namespace std;
const int maxn = 1001010;
ll n, arr[maxn], dp[maxn];
int main() {
cin>>n;
dp[0] = 0;
for(int i=1;i<=n;i++) {
cin>>arr[i];
/*ll maxval = 0LL;
dp[i] = LLONG_MAX;
int lst_j = i;
for(int j=i;j>=1 && arr[j] <= arr[i];j--) {
maxval = max(maxval, arr[j]);
dp[i] = min(dp[i], dp[j-1] + (n - j + 1) * maxval);
lst_j = j;
}
lst_j--;
if(lst_j >= 1) {
dp[i] = min(dp[i], dp[lst_j - 1] + (n - lst_j + 1) * arr[lst_j]);
}*/
}
cout<<arr[1]*n<<"\n";
return 0;
}
# | 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... |