QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#109550#71. Cake 3bashkort#0 5ms3748kbC++201.0kb2023-05-29 17:51:412024-05-31 13:47:18

Judging History

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

  • [2024-05-31 13:47:18]
  • 评测
  • 测评结果:0
  • 用时:5ms
  • 内存:3748kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-29 17:51:41]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

constexpr int N = 101;

ll V[N], C[N];
ll dp[N][N];

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

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        cin >> V[i] >> C[i];
//        V[i] -= 2 * C[i];
    }

    ll ans = -3e18;

    for (int s = 0; s < n; ++s) {
        for (int x = 0; x < n; ++x) {
            fill(dp[x], dp[x] + n, -3e18);
        }
        dp[s][1] = V[s];

        for (int i = s + 1; i < n; ++i) {
            for (int p = s; p < i; ++p) {
                for (int m = 1; m < k; ++m) {
                    dp[i][m + 1] = max(dp[i][m + 1], dp[p][m] + V[i] - abs(C[i] - C[p]));
//                    dp[i][m + 1] = max(dp[i][m + 1], dp[p][m] + V[i] + 2 * min(C[i], C[p]));
                }
            }
            ans = max(ans, dp[i][k] - abs(C[i] - C[s]));
//            ans = max(ans, dp[i][k] + 2 * min(C[i], C[s]));
        }
    }

    cout << ans << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 3748kb

input:

100 32
671208774 266481733
115497791 342597239
326245300 76223942
528973483 754205900
437996819 995535247
100582194 42402057
771100621 351934207
89058009 81951602
768935397 186435060
842907845 376386254
187943947 59424920
997369107 493642356
455078419 68850493
542835555 938351581
970171972 611243076...

output:

20266317099

result:

wrong answer 1st lines differ - expected: '25580474644', found: '20266317099'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%