QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#220651#5303. No Bug No GamebigJWA 11ms39060kbC++202.1kb2023-10-20 17:01:412023-10-20 17:01:41

Judging History

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

  • [2023-10-20 17:01:41]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:39060kb
  • [2023-10-20 17:01:41]
  • 提交

answer

#include <bits/stdc++.h>

template<typename P, typename Q> std::istream& operator>>(std::istream& is, std::pair<P, Q>& v) { std::cin >> v.first >> v.second; return is; }
template<typename P, typename Q> std::ostream& operator<<(std::ostream& os, std::pair<P, Q>& v) { std::cout << v.first << ' ' << v.second; return os; }
template<typename T, std::size_t N> std::istream& operator>>(std::istream& is, std::array<T, N>& v) { for (auto& i : v) is >> i; return is; }
template<typename T, std::size_t N> std::ostream& operator<<(std::ostream& os, std::array<T, N>& v) { for (auto& i : v) os << i << ' '; return os; }
template<typename T> std::istream& operator>>(std::istream& is, std::vector<T>& v) { for (auto& i : v) is >> i; return is; }
template<typename T> std::ostream& operator<<(std::ostream& os, std::vector<T>& v) { for (auto& i : v) os << i << ' '; return os; }
template<typename...Args> void debug(Args...args) { ((std::cerr << args << ' '), ...); std::cerr << '\n'; }
template<typename...Args> void println(Args...args) { ((std::cout << args << ' '), ...); std::cout << '\n'; }
template<typename P, typename Q> void chmax(P& a, Q b) { a = (b > a ? b : a); }
template<typename P, typename Q> void chmin(P& a, Q b) { a = (b < a ? b : a); }

using i64 = long long;

constexpr int N = 3010;

int dp[N][N];
int w[N][11];
int p[N];

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    int n, m;
    std::cin >> n >> m;

    for (int i = 1; i <= n; i++) {
        std::cin >> p[i];
        for (int j = 1; j <= p[i]; j++) {
            std::cin >> w[i][j];
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            chmax(dp[i][j], dp[i - 1][j]);
            if (j + p[i] <= m) {
                chmax(dp[i][j + p[i]], dp[i][j] + w[i][p[i]]);
            }
            else if (j >= m) {
                // do nothing...
            }
            else {
                chmax(dp[i][m], dp[i][j] + w[i][m - j]);
            }
        }
    }

    std::cout << dp[n][m] << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 5
2 1 3
2 1 1
2 3 1
2 1 3

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 11ms
memory: 39060kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

299067290

result:

wrong answer 1st numbers differ - expected: '68279788', found: '299067290'