Submission #433521

#TimeUsernameProblemLanguageResultExecution timeMemory
433521kiennguyen246Discharging (NOI20_discharging)C++14
36 / 100
151 ms13872 KiB
/** * \author Nguyen Duc Kien * \date 20/06/2021 */ ///Task name #define TASK "" ///-------------------------------------------/// #include <bits/stdc++.h> using namespace std; const int maxn = 1e6 + 5; int n, a[maxn]; namespace Sub2 { long long f[2005]; int mx[2005][2005]; void Main() { for (int i = 1; i <= n; i ++) for (int j = 1; j <= n; j ++) mx[i][j] = (i != j ? - 1e9 - 69 : a[i]); for (int i = 1; i <= n; i ++) for (int j = i + 1; j <= n; j ++) mx[i][j] = max(mx[i][j - 1], a[j]); f[0] = 0; for (int i = 1; i <= n; i ++) f[i] = 1e18 + 69; for (int i = 1; i <= n; i ++) { for (int j = 0; j < i; j ++) { f[i] = min({f[i], f[j] + 1ll * mx[j + 1][i] * (n - j)}); } } cout << f[n]; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cerr << "Processing...\n\n"; if (fopen(TASK".INP", "r")) { freopen(TASK".INP", "r", stdin); // freopen(TASK".OUT", "w", stdout); } cin >> n; for (int i = 1; i <= n; i ++) cin >> a[i]; if (n <= 1500) Sub2::Main(); cerr << "\n\n-----------------\n"; return 0; }

Compilation message (stderr)

Discharging.cpp: In function 'int main()':
Discharging.cpp:52:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   52 |         freopen(TASK".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#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...