Submission #156050

# Submission time Handle Problem Language Result Execution time Memory
156050 2019-10-03T03:10:13 Z atoiz 도장 모으기 (JOI14_stamps) C++14
100 / 100
165 ms 71244 KB
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 3007;
const long long INF = 1e15;
int n;
long long u[MAXN], v[MAXN], d[MAXN], e[MAXN], t, f[MAXN][MAXN];
void upd(long long &x, long long y) { if (x > y) x = y; }

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> t;
    for (int i = 1; i <= n; ++i) cin >> u[i] >> v[i] >> d[i] >> e[i];
    for (int i = 1; i <= n + 1; ++i) for (int j = 0; j <= n + 1; ++j) f[i][j] = INF;
    f[1][0] = 0;

    for (int i = 1; i <= n; ++i) {
        for (int j = n; j > 0; --j) if (f[i][j] < INF) upd(f[i][j - 1], f[i][j] + u[i] + e[i]);
        for (int j = 0; j < n; ++j) if (f[i][j] < INF) upd(f[i][j + 1], f[i][j] + d[i] + v[i]);

        for (int j = n; j >= 0; --j) if (f[i][j] < INF) {
            upd(f[i + 1][j], f[i][j] + u[i] + v[i] + j * t * 2);
            upd(f[i + 1][j + 1], f[i][j] + d[i] + v[i] + (j + 1) * t * 2);
            if (j > 0) upd(f[i + 1][j], f[i][j] + d[i] + e[i] + j * t * 2);
            if (j > 0) upd(f[i + 1][j - 1], f[i][j] + u[i] + e[i] + (j - 1) * t * 2);
        }
    }
    cout << f[n + 1][0] + t * (n + 1) << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 760 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 840 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 2 ms 632 KB Output is correct
7 Correct 2 ms 760 KB Output is correct
8 Correct 2 ms 760 KB Output is correct
9 Correct 2 ms 760 KB Output is correct
10 Correct 2 ms 760 KB Output is correct
11 Correct 2 ms 912 KB Output is correct
12 Correct 3 ms 888 KB Output is correct
13 Correct 3 ms 888 KB Output is correct
14 Correct 3 ms 888 KB Output is correct
15 Correct 2 ms 888 KB Output is correct
16 Correct 3 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 71020 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 159 ms 71040 KB Output is correct
4 Correct 142 ms 62840 KB Output is correct
5 Correct 106 ms 51960 KB Output is correct
6 Correct 43 ms 24440 KB Output is correct
7 Correct 29 ms 15352 KB Output is correct
8 Correct 162 ms 71160 KB Output is correct
9 Correct 141 ms 71188 KB Output is correct
10 Correct 159 ms 71160 KB Output is correct
11 Correct 144 ms 71244 KB Output is correct
12 Correct 135 ms 71032 KB Output is correct
13 Correct 135 ms 71032 KB Output is correct
14 Correct 160 ms 71228 KB Output is correct
15 Correct 134 ms 71032 KB Output is correct
16 Correct 135 ms 71036 KB Output is correct
17 Correct 135 ms 71032 KB Output is correct