QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#850980#9987. 骑行计划AlencryenfoTL 0ms0kbC++111.7kb2025-01-10 14:01:372025-01-10 14:01:39

Judging History

This is the latest submission verdict.

  • [2025-01-10 14:01:39]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2025-01-10 14:01:37]
  • Submitted

answer

// an test
#include <bits/stdc++.h>
using namespace std;

const int N = 155;
int f[N][N][N], g[N][N], sum[N][N], s[N];
int n, m, c, mx;

void cmin(int &x, int y) {
    if (y < x) x = y;
}

int main() {
    scanf("%d%d%d", &n, &m, &c);
    for (int i = 1; i <= n; i ++) {
        scanf("%d" , s + i);
        mx = max(mx, s[i]);
    }
    for (int i = 1; i <= mx; i ++) {
        for (int j = 1; j <= n; j ++) {
            sum[i][j] = sum[i][j - 1] + max(0, s[j] - i + 1);
        }
    }

    memset(g, 0x3f, sizeof g);
    for (int i = 1; i <= m; i ++) {
        int w, d, t;
        scanf("%d%d%d", &w, &d, &t);
        cmin(g[min(t, mx)][d], w);
    }
    for (int i = 1; i <= mx; i ++) {
        for (int j = n; j >= 1; j --) {
            cmin(g[i][j], g[i][j + 1]);
        }
    }

    memset(f, 0x3f, sizeof f);
    for (int i = mx; i >= 1; i --) {
        for (int l = n; l >= 1; l --) {
            for (int r = l; r <= n; r ++) {
                f[i][l][r] = (sum[i][r] - sum[i][l - 1]) * c;
                for (int x = l; x <= r; x ++) {
                    for (int y = x; y <= r; y ++) {
                        int tmp = 0;
                        if (l <= x - 1) tmp += f[i][l][x - 1];
                        if (y + 1 <= r) tmp += f[i][y + 1][r];
                        for (int j = i; j <= mx; j ++) {
                            int nw = tmp + g[j][y - x + 1] + (j == mx ? 0 : f[j + 1][x][y]);
                            cmin(f[i][l][r], nw);
                        }
                    }
                }
                // printf("%d %d %d  %d\n", i, l, r, f[i][l][r]);                           
            }
        }
    }   
    cout << f[1][1][n] << endl;

    return 0;
}

详细

Test #1:

score: 0
Time Limit Exceeded

input:

85 5408 4856
52 43 38 21 33 28 24 46 4 66 14 51 63 24 69 35 50 9 63 58 43 69 1 28 59 56 50 63 12 23 41 6 19 9 41 45 14 52 6 7 1 24 30 9 33 54 71 38 55 28 61 10 21 13 22 56 29 24 19 27 9 3 25 54 45 50 9 42 13 5 32 37 56 51 24 3 12 37 68 29 69 40 53 50 69
486593 41 10
175445 13 5
1271250 9 35
7064 1 2...

output:


result: