QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#608971#6462. Jewel ThiefParsley_WA 607ms137584kbC++141.7kb2024-10-04 09:54:262024-10-04 09:54:26

Judging History

你现在查看的是最新测评结果

  • [2024-10-04 09:54:26]
  • 评测
  • 测评结果:WA
  • 用时:607ms
  • 内存:137584kb
  • [2024-10-04 09:54:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define LL long long
struct op {
    int x, y;
    bool operator<(const op &aa)const {
        return x < aa.x || x == aa.x && y > aa.y;
    }
} a[1000005];
int s, d, c[305];
LL b[1000005], dp[305][50005];
const int dd = 300;
template<typename T>inline void read(T &n) {
    T w = 1;
    n = 0;
    char ch = getchar();

    while (!isdigit(ch) && ch != EOF) {
        if (ch == '-')
            w = -1;

        ch = getchar();
    }

    while (isdigit(ch) && ch != EOF)
        n = (n << 1) + (n << 3) + (ch & 15), ch = getchar();

    n *= w;
}
LL gt(int x, int y) {
    return b[min(y + c[x - 1], c[x])] - b[c[x - 1]];
}
void wk(int x, int y, int o, int i, int z, int p) {
    if (x > y)
        return;

    int mid = (x + y) >> 1;
    LL kk = -1;
    int k1;

    for (int g = o; g <= i && g <= mid; g++) {
        LL k2 = dp[z - 1][g * z + p] + gt(z, mid - g);

        if (k2 > kk)
            kk = k2, k1 = g;
    }

    dp[z][mid * z + p] = kk,
                         wk(x, mid - 1, o, k1, z, p), wk(mid + 1, y, k1, i, z, p);
}
int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    read(s), read(d);

    for (int g = 1; g <= s; g++)
        read(a[g].x), read(a[g].y);

    sort(a + 1, a + 1 + s);

    for (int g = 1; g <= s; g++)
        b[g] = b[g - 1] + a[g].y, c[a[g].x] = g;

    for (int g = 1; g <= dd; g++)
        c[g] = max(c[g], c[g - 1]);

    for (int g = 1; g <= dd; g++)
        for (int h = 0; h < g; h++)
            wk(0, (d - h) / g, 0, (d - h) / g, g, h);

    for (int g = 1; g <= d; g++)
        cout << dp[dd][g] << ' ';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 122444kb

input:

4 9
2 8
1 1
3 4
5 100

output:

1 8 9 9 100 101 108 109 109 

result:

ok single line: '1 8 9 9 100 101 108 109 109 '

Test #2:

score: 0
Accepted
time: 0ms
memory: 122440kb

input:

5 7
2 2
3 8
2 7
2 4
3 8

output:

0 7 8 11 15 16 19 

result:

ok single line: '0 7 8 11 15 16 19 '

Test #3:

score: 0
Accepted
time: 0ms
memory: 122356kb

input:

2 6
300 1
300 2

output:

0 0 0 0 0 0 

result:

ok single line: '0 0 0 0 0 0 '

Test #4:

score: -100
Wrong Answer
time: 607ms
memory: 137584kb

input:

1000000 100000
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
1 10
1 11
1 12
1 13
1 14
1 15
1 16
1 17
1 18
1 19
1 20
1 21
1 22
1 23
1 24
1 25
1 26
1 27
1 28
1 29
1 30
1 31
1 32
1 33
1 34
1 35
1 36
1 37
1 38
1 39
1 40
1 41
1 42
1 43
1 44
1 45
1 46
1 47
1 48
1 49
1 50
1 51
1 52
1 53
1 54
1 55
1 56
1 57
1 58
1 59...

output:

1000000 1999999 2999997 3999994 4999990 5999985 6999979 7999972 8999964 9999955 10999945 11999934 12999922 13999909 14999895 15999880 16999864 17999847 18999829 19999810 20999790 21999769 22999747 23999724 24999700 25999675 26999649 27999622 28999594 29999565 30999535 31999504 32999472 33999439 3499...

result:

wrong answer 1st lines differ - expected: '1000000 1999999 2999997 399999...8249997 94999149999 95000050000', found: '1000000 1999999 2999997 399999...824994 48753824994 48753824994 '