Submission #485724

#TimeUsernameProblemLanguageResultExecution timeMemory
485724blueDischarging (NOI20_discharging)C++17
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> using namespace std; using ll = long long; using vll = vector<ll>; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int N; cin >> N; vll t(N+1); t[N] = 0; for(int i = 0; i < N; i++) cin >> t[i]; reverse(t.begin(), t.end()); vll dp(1+N, 1'000'000'000'000'000'000LL); dp[0] = 0; for(int i = 1; i <= N; i++) { ll curr_max = 0; for(int j = i-1; j >= 0; j--) { curr_max = max(curr_max, t[j+1]); dp[i] = min(dp[i], dp[j] + curr_max * i); } } // for(int i = N; i >= 1; i--) // { // ll curr_max = 0; // for(int j = i+1; j <= N+1; j++) // { // curr_max = max(curr_max, t[j-1]); // dp[i] = min(dp[i], dp[j] + curr_max * (N - (i - 1))); // } // } // for(int i = 1; i <= N; i++) // { // ll curr_max = 0; // for(int j = i-1; j >= 0; j--) // { // curr_max = max(curr_max, t[j+1]); // dp[i] = min(dp[i], dp[j] + curr_max * (N - j)); // } // } cout << dp[N] << '\n'; }

Compilation message (stderr)

Discharging.cpp: In function 'int main()':
Discharging.cpp:20:5: error: 'reverse' was not declared in this scope
   20 |     reverse(t.begin(), t.end());
      |     ^~~~~~~