#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
830 ms |
17768 KB |
Output is correct |
2 |
Correct |
840 ms |
17876 KB |
Output is correct |
3 |
Correct |
834 ms |
17920 KB |
Output is correct |
4 |
Correct |
827 ms |
17784 KB |
Output is correct |
5 |
Correct |
829 ms |
17912 KB |
Output is correct |
6 |
Correct |
847 ms |
17900 KB |
Output is correct |
7 |
Correct |
828 ms |
17788 KB |
Output is correct |
8 |
Correct |
835 ms |
17820 KB |
Output is correct |
9 |
Correct |
838 ms |
17876 KB |
Output is correct |
10 |
Correct |
835 ms |
17744 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Incorrect |
1 ms |
384 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |