Submission #433523

# Submission time Handle Problem Language Result Execution time Memory
433523 2021-06-20T03:45:55 Z kiennguyen246 Discharging (NOI20_discharging) C++14
13 / 100
125 ms 4284 KB
/**
 * \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[maxn];
//    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 * a[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

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 time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 332 KB Output is correct
2 Correct 2 ms 332 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 2 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 2 ms 332 KB Output is correct
7 Correct 3 ms 332 KB Output is correct
8 Correct 3 ms 332 KB Output is correct
9 Correct 2 ms 332 KB Output is correct
10 Correct 2 ms 332 KB Output is correct
11 Correct 3 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 328 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Incorrect 93 ms 4284 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 125 ms 4264 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -