Submission #270458

#TimeUsernameProblemLanguageResultExecution timeMemory
270458Haunted_CppDischarging (NOI20_discharging)C++17
36 / 100
1093 ms16036 KiB
/** * author: Haunted_Cpp **/ #include <bits/stdc++.h> using namespace std; #pragma GCC optimize("Ofast") #pragma GCC target("fma,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") template<typename T> ostream &operator << (ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; } template<typename T, size_t size> ostream &operator << (ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; } template<typename A, typename B> ostream &operator << (ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } void debug_out() { cerr << endl; } template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); } #ifdef LOCAL #define debug(...) cerr << "(" << #__VA_ARGS__ << "):", debug_out(__VA_ARGS__) #else #define debug(...) 47 #endif int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<long long> arr(n + 1); for (int i = 1; i <= n; i++) cin >> arr[i]; vector<long long> dp(n + 1, 1e18); dp[0] = 0; for (int i = 1; i <= n; i++) { long long mx = 0; for (int j = i - 1; j >= 0; j--) { mx = max(mx, arr[j + 1]); dp[i] = min(dp[i], dp[j] + 1LL * mx * (n - j)); } } cout << dp[n] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...